为什么如果我为我的主要内容添加一个宽度,它不再包裹我的浮动div?
<div style="float:left;width:30%;">
content1 content1 content1 content1 content1 content1 content1 content1
</div>
<div id="mainContent" style="width:30%;">
content2 content2 content2 content2 content2 content2 content2 content2 content2 content2 content2 content2 content2 content2 content2 content2 content2
</div>
答案 0 :(得分:0)
您的浮动div
应该包含在mainContent
div
中:
<div id="mainContent">
<div style="float:left;width:30%;">
content1 content1 content1 content1 content1 content1 content1 content1
</div>
content2 content2 content2 content2 content2 content2 content2 content2 content2 content2 content2 content2 content2 content2 content2 content2 content2
content2 content2 content2 content2 content2 content2 content2 content2 content2 content2 content2 content2 content2 content2 content2 content2 content2
content2 content2 content2 content2 content2 content2 content2 content2 content2 content2 content2 content2 content2 content2 content2 content2 content2
content2 content2 content2 content2 content2 content2 content2 content2 content2 content2 content2 content2 content2 content2 content2 content2 content2
</div>