請看看我的代碼有什么問題~
<html> <style?type="text/css"> .top{height:100px;background:blue;top:0;margin:0?auto;} .head{background:#ff7a56;height:100px;width:500px;margin:0?auto;} .left{width:100px;height:500px;float:left;background:grey;} .main{height:500px;margin:0?auto;background:pink;top:0;} .right{width:100px;height:500px;float:right;background:#ededed;} </style> <div?class="top"> <div?class="head"></div> </div> <div?class="left">啦啦啦</div> <div?class="main">123</div> <div?class="right">456</div> </html>
請問為什么我最右邊的分欄“456”會跑到下面去~
2016-07-06
.main{height:500px;margin:0?auto;background:pink;top:0;}? 這個里面的margin不能這么寫,你可以直接給mian寫一個寬度,加一個float:left; 你在;兩個浮動之間寫margin沒用,可以試試這樣.main{height:500px; width:500px; float: left;background:pink;top:0;}