CSS列计数导致项目拆分列

Lov*_*ock 2 css css3 masonry

试图不使用jQuery脚本进行砌体效果,因此寻找CSS替代品.

我正在尝试使用列计数,这似乎有效,但不是预期的.

所以列就在那里,但有时容器中的项目被分割为多个,正如您在本示例中应该看到的那样:

http://jsfiddle.net/DTcHh/3858/

#builds {
  width: 100%;
}
.cols {
  -moz-column-count:4;
  -moz-column-gap: 3%;
  -moz-column-width: 25%;
  -webkit-column-count:4;
  -webkit-column-gap: 3%;
  -webkit-column-width: 25%;
  column-count: 4;
  column-gap: 3%;
  column-width: 25%;
}
.item {
  height: auto;
  width: 100%;
}
Run Code Online (Sandbox Code Playgroud)

我正在使用数据库中的项目分页,有时一切正常,但有些则没有.

任何逻辑,为什么/我做错了什么?

fca*_*llo 6

我想就是你需要的

.items {
  -webkit-column-break-inside: avoid;
  -o-column-break-inside: avoid;
  -moz-column-break-inside: avoid;
  break-inside: avoid;
}
Run Code Online (Sandbox Code Playgroud)