a有三个列布局,我想在中间列中有三个div,但每次我的内容在边栏比中间div的内容“更长”时,盒子在“最长的div”下跳下去。这里是我的代码:在3列布局的中间的清晰元素
<div style="float: left; width: 15%; background-color: yellow;">
<p>left</p>
<p>left</p>
<p>left</p>
</div>
<div style="float: right; width: 15%; background-color: pink;">
<p>right</p>
<p>right</p>
<p>right</p>
<p>right</p>
</div>
<div style="margin-left: 20%; margin-right: 20%;">
<div style="float: left; width: 20%; background-color: blue; margin: 1%">
middle
</div>
<div style="float: left; width: 20%; background-color: blue; margin: 1%">
middle
</div>
<div style="float: left; width: 20%; background-color: blue; margin: 1%">
middle
</div>
<div style="clear: both;"></div>
<div style="float: left; width: 20%; background-color: blue; margin: 1%">
middle
</div>
<div style="float: left; width: 20%; background-color: blue; margin: 1%">
middle
</div>
<div style="float: left; width: 20%; background-color: blue; margin: 1%">
middle
</div>
<div style="clear: both;"></div>
<div style="float: left; width: 20%; background-color: blue; margin: 1%">
middle
</div>
<div style="float: left; width: 20%; background-color: blue; margin: 1%">
middle
</div>
<div style="float: left; width: 20%; background-color: blue; margin: 1%">
middle
</div>
这里是为了更好地理解在jsfiddle代码。如果有人能够向我解释“清算”,我会很高兴。
编辑: 我跟着这个教程http://css.maxdesign.com.au/floatutorial/tutorial0406.htm
好吧,我明白了。我只是认为这是正确的方式(我后面添加的教程),但正如我所看到的,当其他浮动元素存在时,它不起作用。感谢您的回答。 – Meph 2012-03-20 15:34:06
本教程适用,因为它们本身就是列,然后它们被分成若干行。身高相同也容易,但列内的列是一种痛苦! – cchana 2012-03-20 15:55:08