0
我被困在一個問題上,它創建一個圖像網格,我無法弄清楚當我到達容器的末尾時如何在下一行開始鋪設項目。我知道我可以使用砌體,但與此相關的問題是我的畫廊需要全寬和砌體,你會得到1px空白問題masonry 1px issue。而只是使用普通的花車也不適合我,因爲我的物品有不同的高度。我如何能解決這個問題的任何想法將是真棒使用jquery創建我自己的圖像畫廊網格
function layout() {
var itemPos = 0;
var itemHeight = [];
$('.gallery__item-list .gallery__item').each(function(index) {
itemHeight.push($(this).height());
$(this).css({
transform: "translate3d(" + itemPos + "px,0px,0)"
});
itemPos += $(this).width();
});
}
CSS
.gallery__item,.grid-sizer {
width: 100%;
position: absolute;
top: 0;
left: 0;
}
@media screen and (min-width: 400px) {
.gallery__item,.grid-sizer {
width: 50%;} }
@media screen and (min-width: 600px) {
.gallery__item,.grid-sizer {
width: 33.333%;}
.gallery__item--body-posts{
margin-bottom: 0px;
} }
@media screen and (min-width: 1000px) {
.gallery__item,.grid-sizer {
width: 25%;
} }