【发布时间】:2023-04-02 04:23:01
【问题描述】:
通常当我在容器 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 类中添加一些内容来使其工作?
【问题讨论】:
标签: html css fluid-layout