官方的解決方法是為父塊加上邊框之類的東西(但是border不能為0)。但是這樣會影響頁面的美觀。所以想了一下之后,決定在父塊中再加入一個空白的字塊2(高度不能為0),這樣原來的字塊1就不會和父塊合并。
效果圖如下:
圖1
圖2
實現代碼如下(簡要):
html:
<div id="whole">
<div style="height:10px;"></div>
<div id="the-table"></div>
</div>
<div style="height:10px;"></div>
<div id="the-table"></div>
</div>
css:
#whole{
background-image:url("../images/bg/client_common_bg.jpg");
width:1006px;
height:513px;
margin:0px auto;
float:none;
}
#the-table{
margin:0px auto;
margin-top:50px;
width:605px;
}
background-image:url("../images/bg/client_common_bg.jpg");
width:1006px;
height:513px;
margin:0px auto;
float:none;
}
#the-table{
margin:0px auto;
margin-top:50px;
width:605px;
}
注:本代碼只在firefox中測試,其他瀏覽器請自行測試(尤其是IE)