css 等高布局

來源:互聯網
上載者:User

標籤:

做一些後台項目,和一下帶側邊欄項目的時候登高布局很常用,總結了下有幾種

1.margin-bottom方法

這裡直接介紹我認為的最佳的側邊欄/分欄高度自動相等方法。核心的CSS代碼如下(數值不固定):

margin-bottom:-3000px; padding-bottom:3000px;

再配合父標籤的overflow:hidden屬性即可實現高度自動相等的效果。

舉個簡單的執行個體吧,如下CSS及HTML代碼:

#content{overflow:hidden;}.left{width:200px; margin-bottom:-3000px; padding-bottom:3000px; background:#cad5eb; float:left;}.right{width:400px; margin-bottom:-3000px; padding-bottom:3000px; background:#f0f3f9; float:right;}.center{margin:0 410px 0 210px; background:#ffe6b8; height:600px;}
<div id="content">    <div class="left">左邊,無高度屬性,自適應於最高一欄的高度</div>    <div class="right">右邊,無高度屬性,自適應於最高一欄的高度</div>    <div class="center">中間,高度600像素,左右兩欄的高度與之自適應</div></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.