我正在尝试使用 Masonry 构建带有图像的流畅多列布局。在某些浏览器大小下,多列会翻转为一列。有没有办法来解决这个问题?
代码笔: http ://codepen.io/anon/pen/dloAe
$(function(){
var $container = $('#container');
$container.imagesLoaded( function(){
$(window).resize(function(){
$container.masonry({
itemSelector: '.item',
isResizable: false,
});
}).resize();
});
});
img {
max-width: 100%;
}
#container {
max-width: 1280px;
margin: 0 auto;
}
.item {
float: left;
width: 46%;
padding: 2%;
}
<div id="container">
<div class="item">
<img src="http://upload.wikimedia.org/wikipedia/commons/thumb/f/f8/Rho_Ophiuchi.jpg/611px-Rho_Ophiuchi.jpg">
</div>
<div class="item">
<img src="http://upload.wikimedia.org/wikipedia/commons/c/cb/Hess_maloyaroslavets.jpg">
</div>
<div class="item">
<img src="http://upload.wikimedia.org/wikipedia/commons/thumb/f/f8/Rho_Ophiuchi.jpg/611px-Rho_Ophiuchi.jpg">
</div>
<div class="item">
<img src="http://upload.wikimedia.org/wikipedia/commons/c/cb/Hess_maloyaroslavets.jpg">
</div>
</div>