聖盃佈局:兩邊固定,中間自適應;佈局
元素代碼:spa
<div class="box"> <div class="content"> </div> <div class="left">左</div> <div class="right">右</div> </div>
佈局代碼:code
雙飛翼佈局:blog
給中間部分在套上一層容器,這樣作之後,大的容器就再也不須要設置padding值,左右欄盒子也不用再設置相對佈局,代碼精簡了不少,並且不會出現變的特別窄佈局會亂掉的問題。it
<div class="box"> <div class="cont"> <div class="center"> 內容 </div> </div> <div class="left"> 左 </div> <div class="right"> 右 </div> </div>
佈局代碼:io
.box{ width: 800px; height: 400px; border:1px solid red; margin:100px auto; } .box>div{ float: left; height: 400px; } .cont{ width: 100%; } .center{ background: red; margin: 0 200px; height: 400px; } .left{ background: blue; width: 200px; margin-left: -100%; } .right{ background: pink; width: 200px; margin-left: -200px; }
構造效果是這樣,class