我想問如何做DIV浮動左邊,但填充垂直空間的DIV上面。我在這裏找到了使用Masonry JQuery插件的解決方案,但是我想問一下是否可以簡單地通過css來完成。如果你看下面的代碼或者jsfiddle,我需要將BOX5與BOX2垂直對齊,所以沒有空間。謝謝浮動DIVs垂直空間
請參閱的jsfiddle:http://jsfiddle.net/9ahxjzm8/
HTML:
<div class="wrapper">
<div class="box">
BOX1
fgwertgege
erhehethrtjh
sthsrtjhrt
rthrthrt
ehertuyrtyr
</div>
<div class="box">
BOX2
sadgergwerwert
adrfgaeghr
</div>
<div class="box">
BOX3
sefweflj
gewrgheher5y
tryjrtjhr
rthrthrthrthrth
</div>
<div class="box">
BOX4
sgwhej rtjrtjktyt
dfgherthrthrt rth rtst
ert erterty
ertye ryeryewe w ergerge r gertgerg
</div>
<div class="box">
BOX5
agwerheh
etherthrtjhr
ertherthrthrth
ergergyhr
</div>
</div>
CSS:
div.box {
width: 500px;
}
div.box {
width: 30%;
background-color:green;
float:left;
border: 1px solid;
margin-left: 5px;
word-wrap: break-word;
}
如果你不知道你的專欄的高度,你可以按照[本教程](http: //matthewjamestaylor.com/blog/equal-height-columns-cross-browser-css-no-hacks) – 2014-11-21 20:16:32
謝謝,但那不是我所需要的,我想擁有不同高度的列 – 2014-11-21 20:31:46