[英]How to load background of parent content first?
我有這樣的設計:
<div id='container'>
<div class='box'>
<div class='boxleft'>something left</div>
<div class='boxright'>something right</div>
<div class='clear'/>
</div>
</div>
我將CSS設置為:
*{margin:0; padding:0}
.clear{clear:both}
#container{width:100%; height:auto; background:#f1f2f3}
.box{width:95%; margin:0 auto; height:auto; background:white}
.boxleft{float:left;width:49%;margin-right:1%;}
.boxright{float:right;width:50%;}
問題:類.box
背景是白色,稍后在類.boxleft
完成加載后加載。 我現在要加載背景跟隨類.boxleft
的高度。 那么,我該怎么做?
感謝您的建議。
您的問題是左浮動和右浮動的結果,而主框內的兩個框都沒有高度。 將此添加到您的.boxleft和.boxright中:
display:block
那應該工作。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.