這裏介紹下float佈局的幾種常見佈局方式,若是對基礎知識有疑問能夠去看一下上一篇文章CSS浮動基礎知識css
顧名思義流體佈局就是佈局格式能夠隨着窗口大小的變化而變化,具體實現以下html
代碼演示(後續CSS代碼均在此代碼基礎上進行修改)ide
<body> <div class="container clearfix"> <main class="main"> <div class="content"></div> </main> <aside class="aside" ></aside> </div> <p>testtesttest</p> </body> </html>
CSS代碼佈局
<style type="text/css"> .main{ width:100%; float:left; } .content{ height:300px; margin:0 200px; background:yellow; } .aside{ width:180px; height:300px; background:red; float:left; margin-left:-100%; /*流體佈局的重點是邊欄的左邊距-100%,經過負值能夠將元素強行拉到上一行*/ } </style>
處理結果以下code