css那些事兒2 經典兩列布局

來源:互聯網
上載者:User

標籤:padding   底部   pad   isp   hit   absolute   pre   color   osi   

 1 <!DOCTYPE html> 2 <html> 3 <head> 4     <title></title> 5     <link rel="stylesheet" type="text/css" href="css/main.css"> 6 </head> 7 <body> 8     <div id="header">頭部</div> 9     <div id="container">10         <div class="mainBox">11             內容地區12             <p>我說情愛的請大賽撒謊和大嫂多少</p>13             <p>hsdaufhsalfsa</p>14             <p>shhsaldhsakl</p>15             <p>我說情愛的請大賽撒謊和大嫂多少</p>16             <p>hsdaufhsalfsa</p>17             <p>shhsaldhsakl</p>18             <p>我說情愛的請大賽撒謊和大嫂多少</p>19             <p>hsdaufhsalfsa</p>20             <p>shhsaldhsakl</p>21             <p>我說情愛的請大賽撒謊和大嫂多少</p>22             <p>hsdaufhsalfsa</p>23             <p>shhsaldhsakl</p>24             <p>我說情愛的請大賽撒謊和大嫂多少</p>25             <p>hsdaufhsalfsa</p>26         </div>27         <div class="sideBox">28             側邊欄29             <span>把手</span>30         </div>31     </div>32     <div id="footer">底部</div>33 </body>34 </html>
 1 body{ 2     padding: 0px; 3     margin: 0px; 4 } 5  6 #header,#footer{ 7     height: 50px; 8     background-color: #e9e9e9; 9 10 }11 12 #container{13     position: relative;14     overflow: hidden;15     margin: 10px 0px;16 }17 18 #container:after{19     display: block;20     content: "";21     line-height: 0px;22     font-size: 0px;23     clear: both;24     visibility: hidden;25 }26 27 .mainBox{28     margin-left: 320px;29     background-color: green;30     width: auto;31     color: white;32 }33 34 .sideBox{35     width: 300px;36     height: 500px;37     position: absolute;38     left: 0px;39     top: 0px;40     background: #234567;41 }42 43 .sideBox span{44     background: red;45     color: white;46     right: 0px;47     position: absolute;48     top: 50%;49     width: 30px;50     height: 50px;51     text-align: center;52 }

 

要想兩列等高一般採用js進行計算設定,如果採用css則可以使用背景填充辦法,或者背景色填充辦法,但都不是太好

css那些事兒2 經典兩列布局

聯繫我們

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