關於左邊固定,右邊調適型配置的響應式布局寫法,自適應寫法

來源:互聯網
上載者:User

關於左邊固定,右邊調適型配置的響應式布局寫法,自適應寫法

關於響應式布局現才接觸到,雖然代碼很簡單,但是對基礎要求還是有一些。

1.left設定position:absolute和width:70px;那麼右邊用margin-left:70px;因為是響應式的我用jquery設定了一下高度(不用jquery,直接設定高度為100%好像不行,不知道為什麼有知道的小夥伴,可以在下面留言,有改進的也可以在下面留言);代碼如下

<!DOCTYPE html><html>    <head>        <meta charset="UTF-8">        <title></title>        <style type="text/css">           html{ height: 100%;}           body{ margin: 0; height: 100%;}           .left{               position: absolute;               width: 88px;               height:100%;
background:red; } .right{ margin-left: 88px; border: 1px red solid;
background:blue; } </style> <script src="js/jquery.min.js"></script> <script type="text/javascript"> $(function(){ $(".right").css("height",$(window).height()+"px"); $(window).resize(function(){ $(".right").css("height",$(window).height()+"px"); }); }); </script> </head> <body> <div class="container"> <div class="left"></div> <div class="right"></div> </div> </body></html>

2.左邊浮動,右邊overflow:auto;

<!DOCTYPE html><html>    <head>        <meta charset="UTF-8">        <title></title>        <style type="text/css">           html{ height: 100%;}           body{ margin: 0; height: 100%;}           .left{               float:left;               width: 88px;               background:red;           }           .right{               overflow: auto;               height: 200px;               background: blue;           }        </style>        <script src="js/jquery.min.js"></script>        <script type="text/javascript">           $(function(){               $(".right").css("height",$(window).height()+"px");               $(window).resize(function(){               $(".right").css("height",$(window).height()+"px");                   });           });           $(function(){               $(".left").css("height",$(window).height()+"px");               $(window).resize(function(){               $(".left").css("height",$(window).height()+"px");                   });           });        </script>    </head>    <body>

 

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.