CSS3列是你要找的。下面是一個示例,HTML:
<div class = "container">
<div class = "entry">Glee is awesome!<br/>1</div>
<div class = "entry">Glee is awesome!<br/>2</div>
<div class = "entry">Glee is awesome!<br/>3</div>
<div class = "entry">Glee is awesome!<br/>4</div>
<div class = "entry">Glee is awesome!<br/>5</div>
<div class = "entry">Glee is awesome!<br/>6</div>
<div class = "entry">Glee is awesome!<br/>7</div>
<div class = "entry">Glee is awesome!<br/>8</div>
</div>
CSS:
.container {
height: 230px; /*2 * 100 + 3 * 10*/
width: 450px; /*2 * 400 + 5 * 10*/
-moz-column-count: 4;
-webkit-column-count: 4;
column-count: 4; /*4 columns*/
}
.entry {
height: 100px;
width: 100px;
margin: 10px;
background-color: rgb(0, 162, 232);
color: white;
font-family: 'Arial', Helvetica, Sans-Serif;
text-align: center;
font-weight: bold;
}
還有一點演示:little link。
我希望有幫助!