css的雙飛翼布局

來源:互聯網
上載者:User

標籤:順序   doctype   type   css   org   變化   back   sdfsdf   idt   

雙飛翼布局的大概意思就是左右兩邊的內容是固定的,大小是固定的,

而中間的布局的隨著頁面的大小變化而自動變化的。

通過代碼來解析:

1.四個div,也可以使用section,其中main,left.right為同一級的元素,inner為main的子項目。

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

3.main的寬度為100%,即佔滿這個頁面。

4.設定left的margin-left:-100%;既讓left與main在同水平線上,處在最左邊。

5.設定right的margin-left:-200px,其中200px為right的寬度,讓right停在最右側。

6.設定main的子項目inner,width與main一樣,margin的順序為上、右、下、左,所以margin:0px 200px 0px 200px,

表示離左邊200px,離右邊200px,其中前者為left的寬度,後者為right的寬度。

<!DOCTYPE html><html lang="en" xmlns="http://www.w3.org/1999/xhtml"><head>    <meta charset="utf-8" />    <title>雙飛翼布局</title>    <style>        body {            margin: 0px;            padding: 0px;            min-width: 500px;        }                #main {            width: 100%;            height: 200px;            background-color: red;            float: left;        }                #left {            width: 200px;            height: 200px;            background-color: blue;            float: left;            margin-left: -100%;        }                #right {            width: 200px;            height: 200px;            background-color: green;            float: left;            margin-left: -200px;        }                #inner {            margin: 0px 200px 0px 200px;            background-color: pink;            height: 200px;            word-break: break-all;        }    </style></head><body>    <div id="main">        <div id="inner">
fdsfsdfsdfsdf
fdsfsdfsdfsdf
fdsfsdfsdfsdf
fdsfsdfsdfsdf
fdsfsdfsdfsdf
</div> </div> <div id="left"></div> <div id="right"></div></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.