<style>
div#float {
text-align: center;
float: left;
width: 150px;
height: 150px;
border: 1px solid blue;
background: gold;
}
div.content {
background: yellow;
border: 1px solid purple;
height: 150px;
}
</style>
<div id='float'>
Float text.
</div>
<div class='content'>
Content text.
</div>
<div class='content'>
Content text.
</div>有人能解释一下第二个div的内容是怎么出现在换行符上的吗?而第一个div是内联的div#float?
发布于 2010-08-01 21:10:07
默认情况下,div将占据整个块的宽度。第一个是在浮动的div之后开始的,因为这是它可以开始的地方。因为您的两个内容div都是块级元素,所以它们将占用它们可用的全部宽度。
有很多方法可以控制这一点,但我不确定你想要什么。
https://stackoverflow.com/questions/3382114
复制相似问题