The easiest option is to use the jQuery Masonry plugin.
If you want to do this only with CSS, you will have to float large columns with the same width, and then add variable height elements to them.
<div class="parent"> <div class="child"></div> <div class="child"></div> <div class="child"></div> </div> <div class="parent"> <div class="child"></div> <div class="child"></div> </div>
And CSS will look like this:
.parent { float: left; width: 200px; } .child { }
source share