【发布时间】:2014-08-31 17:53:29
【问题描述】:
一个疑问:
我为 div 赋予 float:left 并在 div 中放置另一个块元素,例如 h3。然后它给出填充顶部和底部。如果我删除 float: left 它不会提供填充。
html
<div class="one"><h3>Test with Float</h3></div>
<div class="clear"> </div>
<div class="two"><h3>Test without Float</h3></div>
css
.one{
background: grey;
float:left;
width: 100%;
}
.two{
background: #DAD5C1;
width: 100%;
}
.clear{
clear: both;
}
【问题讨论】:
-
请将您的代码放入问题中,或者根本不要费心链接到小提琴。不要绕过质量过滤器。
-
不好的提问方式,但有趣的问题。
-
感谢 rnrneverdies