これは、firefox と chrome でのみ可能です。CSS での純粋な組積造レイアウトはまったく不可能です。Internet Explorer のフォールバックについては、packery を参照してください: http://packery.metafizzy.co/
編集:すべてのボックスの高さが同じ場合:各ボックスに float:left を追加します
デモ: http://jsfiddle.net/umbriel/tQANc/
デモ V2: http://jsfiddle.net/umbriel/TzkZ8/
デモ V3 IE 互換: http://jsfiddle.net/umbriel/6e6Qy/
HTML:
<div id="container" class="cols">
<div class="box one"></div>
<div class="box two"></div>
<div class="box one"></div>
<div class="box three"></div>
<div class="box two"></div>
<div class="box five"></div>
<div class="box one"></div>
<div class="box two"></div>
<div class="box six"></div>
<div class="box three"></div>
<div class="box two"></div>
</div>
CSS:
#container {
width: 100%;
max-width: 700px;
margin: 2em auto;
}
.cols {
-moz-column-count:3;
-moz-column-gap: 3%;
-moz-column-width: 30%;
-webkit-column-count:3;
-webkit-column-gap: 3%;
-webkit-column-width: 30%;
column-count: 3;
column-gap: 3%;
column-width: 30%;
}
.box {
margin-bottom: 20px;
}
.box.one {
height: 200px;
background-color: #d77575;
}
.box.two {
height: 300px;
background-color: #dcbc4c;
}
.box.three {
background-color: #a3ca3b;
height: 400px;
}
.box.four {
background-color: #3daee3;
height: 500px;
}
.box.five {
background-color: #bb8ed8;
height: 600px;
}
.box.six {
background-color: #baafb1;
height: 200px;
}