實施例:https://jsfiddle.net/5tehhb0n/1/在Chrome
HTML:
<div class="wrapper">
<div class="item"><img src="http://placehold.it/100x100"></div>
<div class="item"><img src="http://placehold.it/100x100"></div>
<div class="item"><img src="http://placehold.it/100x100"></div>
<div class="item"><img src="http://placehold.it/100x100"></div>
<div class="item"><img src="http://placehold.it/100x100"></div>
<div class="item"><img src="http://placehold.it/100x100"></div>
<div class="item"><img src="http://placehold.it/100x100"></div>
<div class="item"><img src="http://placehold.it/100x100"></div>
<div class="item"><img src="http://placehold.it/100x100"></div>
</div>
CSS:
.wrapper {
-moz-column-count: 2;
-webkit-column-count: 2;
column-count: 2;
background-color: blue;
display: block;
overflow: hidden;
}
.item {
-webkit-column-break-inside: avoid;
display: block;
background-color: red;
margin-bottom: 50px;
}
在鉻,這導致在第一項中的第二列上有一個空格,由第一列最後一項的空白引起:
設置display: inline-block
每個.item
解決了這個問題,但我需要保持邊緣摺疊,這不適用於inline-block
。
有沒有辦法避免額外的空間,並仍然保持每.item
display: block
?
刪除邊距:50像素; – grasig