css的聖杯布局

來源:互聯網
上載者:User

標籤:ebe   device   view   cti   代碼   title   解析   relative   width   

聖杯布局和雙飛翼布局實現的效果是一樣的。

代碼解析:

1.四個section,container,main,left,right。其中那個container為父容器。

2.main,left,right均左浮動。

3.main的寬度為100%。

4.設定left的margin:-100%。

5.設定rightd margin:-200px;

6.設定父容器的內邊距padding:0px 200px 0px 200px。

7.設定left的positon:relative;left:-200px.

8.設定right的position:relative:right;right:-200px;

<!DOCTYPE html><html lang="en"><head>    <meta charset="UTF-8">    <meta name="viewport" content="width=device-width, initial-scale=1.0">    <meta http-equiv="X-UA-Compatible" content="ie=edge">    <title>Document</title>    <style>        body {            min-width: 700px;        }                #container {            padding: 0px 200px 0px 200px;        }                #main {            height: 200px;            width: 100%;            float: left;            background-color: rebeccapurple;            word-break: break-all;        }                #left {            height: 200px;            width: 200px;            float: left;            background-color: gold;            margin-left: -100%;            position: relative;            left: -200px;        }                #right {            height: 200px;            width: 200px;            float: left;            background-color: firebrick;            margin-left: -200px;            position: relative;            right: -200px;        }    </style></head><body>    <section id="container">        <section id="main">            gfdgdfg gdfgfdg gfdgdfg gdfgfdggfdgdfg gdfgfdggfdgdfg gdfgfdg        </section>        <section id="left"></section>        <section id="right"></section>    </section></body></html>

  

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.