通常当我在容器 div 中有浮动元素时,我会有这样的东西:
<div class="container">
<div style="float: left;">content</div>
<div style="float: left;">content</div>
<div style="clear:both;"></div>
</div>
我发现<div style="clear:both;"></div>
在每一个流畅的布局上都有它非常烦人和丑陋。所以我尝试做这样的事情(使用css,但为简单起见):
<div class="container" style="clear:both;">
<div style="float: left;">content</div>
<div style="float: left;">content</div>
</div>
并没有工作。是否可以通过在课堂上添加一些东西来使其工作.container
?