例图:
代码实现:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
<style>
@media screen and (max-width: 800px) {
.masonry {
column-count: 2;
}
}
@media screen and (max-width: 500px) {
.masonry {
column-count: 1;
}
}
.masonry {
-moz-column-count:2; /* Firefox */
-webkit-column-count:2; /* Safari 和 Chrome */
column-count:2;
-moz-column-gap: 2em;
-webkit-column-gap: 2em;
column-gap: 2em;
width: 90%;
margin:2em auto;
column-fill:balance;
}
.item {
padding: 1em;
margin-bottom: 2em;
-moz-page-break-inside: avoid;
-webkit-column-break-inside: avoid;
break-inside: avoid;
background: #f60;
}
</style>
</head>
<body>
<div class="masonry">
<div class="item">
<div> 1
lkjasdfjafja昆仑剑法撒旦撒发卡机<br>
lkjasdfjafja昆仑剑法撒旦撒发卡机<br>
lkjasdfjafja昆仑剑法撒旦撒发卡机<br>
</div>
</div>
<div class="item">
<div> 2
</div>
</div>
<div class="item">
<div> 3
lkjasdfjafja昆仑剑法撒旦撒发卡机<br>
lkjasdfjafja昆仑剑法撒旦撒发卡机<br>
</div>
</div>
<div class="item">
<div> 4
</div>
</div>
<div class="item">
<div> 5
</div>
</div>
<div class="item">
<div class="item_content content-lar"> 6
lkjasdfjafja昆仑剑法撒旦撒发卡机<br>
lkjasdfjafja昆仑剑法撒旦撒发卡机<br>
lkjasdfjafja昆仑剑法撒旦撒发卡机<br>
lkjasdfjafja昆仑剑法撒旦撒发卡机<br>
</div>
</div>
<div class="item">
<div class="item_content content-sma"> 7
lkjasdfjafja昆仑剑法撒旦撒发卡机<br>
lkjasdfjafja昆仑剑法撒旦撒发卡机<br>
lkjasdfjafja昆仑剑法撒旦撒发卡机<br>
lkjasdfjafja昆仑剑法撒旦撒发卡机<br>
lkjasdfjafja昆仑剑法撒旦撒发卡机<br>
lkjasdfjafja昆仑剑法撒旦撒发卡机<br>
lkjasdfjafja昆仑剑法撒旦撒发卡机<br>
lkjasdfjafja昆仑剑法撒旦撒发卡机<br>
</div>
</div>
<div class="item">
<div class="item_content content-lar"> 8
lkjasdfjafja昆仑剑法撒旦撒发卡机<br>
lkjasdfjafja昆仑剑法撒旦撒发卡机<br>
lkjasdfjafja昆仑剑法撒旦撒发卡机<br>
lkjasdfjafja昆仑剑法撒旦撒发卡机<br>
lkjasdfjafja昆仑剑法撒旦撒发卡机<br>
lkjasdfjafja昆仑剑法撒旦撒发卡机<br>
lkjasdfjafja昆仑剑法撒旦撒发卡机<br>
lkjasdfjafja昆仑剑法撒旦撒发卡机<br>
</div>
</div>
<div class="item">
<div class="item_content content-lar"> 9
</div>
</div>
<div class="item">
<div class="item_content content-sma"> 10
</div>
</div>
<div class="item">
<div class="item_content content-mid"> 11
</div>
</div>
<div class="item">
<div class="item_content content-mid"> 12
</div>
</div>
<div class="item">
<div class="item_content content-mid"> 13
</div>
</div>
<div class="item">
<div class="item_content content-mid"> 14
</div>
</div>
<!-- more items -->
</div>
</body>
</html>