此CSS是爲了實現三列布局:左右固定,中間自適應;且瀏覽器會自上而下先出現中間部分。html
html:
<body> <!-- 使得瀏覽器先出來center --> <div class="box"> <div class="center"> <!-- 建立一個div 開造 --> <div class="inner"></div> </div> <div class="left"></div> <div class="right"></div> </div>
</body>瀏覽器
CSS:
<style> .box { width: 100%; height: 300px; background: darkblue; margin: 0 auto; } .center { width: 100%; height: 100%; float: left; } .inner { /* width: 100px; height: 100%; background: darkmagenta; */ margin: 0; } .left { width: 100px; height: 100%; background: darkgoldenrod; float: left; margin-left: -100%; } .right { width: 100px; height: 100%; background: darkred; float: left; margin-left: -100px; } </style>
最後效果出來是這樣的微信
聽說認真閱讀並點讚的你,代碼敲的最6哦~ 有興趣的小夥伴能夠加我微信,一塊兒討論;V-x: dandanshen987佈局