砖石不会填补我网格中的空白

masonry won't fill in the gaps in my grid

我有这个砖石网格,我试图设置 http://codepen.io/soursocks/pen/QKLGrR

但由于某些原因,网格不会自己填满。

我认为这可能是我的 css 的问题。

可能与

有关
 .grid-items {
    background: black;
    margin-left: 0;
}

/* items are not quite 1/3 wide */
.item {
    float: left;
    width: 33.2%;
}

/* images cover up the gap */
.item img {
    display: block;
    width: 100.5%;
}

我按照我在此处看到的示例进行操作 http://codepen.io/desandro/pen/myBxD 但似乎无法重现效果

我知道之前有人发过这个帖子,但我找不到能回答我问题的帖子

你只犯了2个错误

在您的 html 中删除网格项目前的点

<div class="grid-items">

并在您的 js 部分中包含 masonry js

http://rawgithub.com/desandro/masonry/v2.1.08/jquery.masonry.js