div css左邊固定右邊調適型配置

來源:互聯網
上載者:User

標籤:html   alt   ide   ons   foo   設定   targe   lazy   nbsp   

web前端開發之布局:先看,最簡單的左右布局。有可能還會被面試問道哈哈哈。一看也沒什麼特別之處,就是左邊固定,右邊自適應,就這麼簡單。

原理:通過設定一個margin-left;或者margin-right就可以搞定。方法有很多,這次就只介紹這種設定margin的。

 代碼:

<!doctype html><html> <head>  <meta charset="UTF-8">  <title>Document</title>    <style>    body{        margin:0;        padding:0;    }           #wrap {            overflow: hidden; *zoom: 1;        }        #content ,#sidebar {            #eee;         }        #sidebar {            float: left; width: 300px;            background-color:pink;            position:fixed;            top:50px;            left:0;        }        #content {            margin-left: 310px;            height:1000px;            background-color:#e456aa;            margin-top:50px;        }        #footer {            background-color: #f00;            color:#fff;             margin-top: 1em;        }    </style>  </head> <body>    <div style="width:100%;height:50px;line-height:50px;background-color:#ccc;position:fixed;top:0;left:0;">這是頭部:web前端開發大全</div>    <div id="wrap">        <div id="sidebar" style="height:600px;">固定寬度區:號:jingfeng18</div>        <div id="content" style="height:1340px;">自適應區</div>    </div>    <div id="footer">這是尾部,想寫什麼就寫什麼,這是一個神奇的地方</div> </body>    </html>

   

非常簡單,如果你還有更好的方法,歡迎前來投稿交流。只為學習更多,技術更上一層樓,早日升職加薪,贏取白富美,走上人生巔峰。學習更多前端技術就在:web前端開發視大全

請記住我們的網站:http://www.qianduanshiping.com  號:jingfeng18

div css左邊固定右邊調適型配置

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.