CSS 經典三列布局

來源:互聯網
上載者:User

標籤:break   back   position   ade   bre   java   inner   頭部   nbsp   

一 聖杯布局

1 html結構

<!DOCTYPE html><html><head><title></title><link rel="stylesheet" type="text/css" href="css/css.css"></head><body><div class="header">頭部</div><div class="container"><div class="middle">中間</div><div class="left">左側</div><div class="right">右側</div></div><div class="footer">底部</div></body></html>

2 css

*{padding: 0;margin: 0;list-style: none;}body{min-height: 700px;}.header,.footer{background: #ff9999;text-align: center;height: 50px;line-height: 50px;}.left,.middle,.right{position: relative;float: left;min-height: 530px;line-height: 530px;text-align: center;}.container{padding: 0 220px 0 200px;overflow: hidden;}.left{margin-left: -100%;left: -200px;width: 200px;background-color: #99ffff;}.right{margin-left: -220px;right: -220px;width: 220px;background: #ccff99;}.middle{width: 100%;background: #ccffff;word-break: break-all;}.footer{clear: both;}

 

二 雙飛翼布局

1 html結構

<!DOCTYPE html><html><head><title></title><link rel="stylesheet" type="text/css" href="css/sb.css"></head><body><div class="header">header</div><div class="middle"><div class="middle-inner">middle</div></div><div class="left">left</div><div class="right">right</div><div class="footer">footer</div></body></html>

2 css

*{padding: 0px;margin: 0px;}.header,.footer{height: 50px;line-height: 50px;background: #cf9999;    border: 1px solid #333;    text-align: center;}.left,.middle,.right{float: left;min-height: 500px;line-height: 500px;text-align: center;}.left{margin-left: -100%;width: 200px;background: #9999ff;}.right{margin-left: -220px;width: 220px;background: #ccffff;}.middle{width: 100%;}.middle-inner{margin-left: 200px;margin-right: 220px;min-height: 500px;background-color: #ccff99;word-break: break-all;}.footer{clear: both;}

  

三 以上兩種 經典布局以雙飛翼為最佳,在此基礎上進行各種變種,主要體現了浮動和margin負值的巧妙使用

 

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.