【发布时间】:2017-08-24 22:49:21
【问题描述】:
在第一个 sn-p 中,您应该会看到 4 张图片分组到左侧 2 列:
[+][+][ ]
[+][+]
并没有像我预期的那样分布在所有 3 列中:
[+][+][+]
[+]
更糟糕的是,即使是 3 列布局中的 3 个项目也会失败!我在 Chrome 中得到了这个:
[+][+][ ]
[+]
而不是这个(这似乎很明显):
[+][+][+]
天哪,为什么?它是一个错误吗?还是没有明确设置列的高度?就流体/动态内容而言,显式高度对列的要求不高(这是我的情况)。
3 列中的 4 项(在 Chrome 和 Firefox 中失败)
p{
-moz-column-count: 3;
column-count: 3;
-moz-column-gap: 0;
column-gap: 0;
-moz-column-fill: balance;
column-fill: balance;
outline:1px solid gray;
}
img{
display: inline-block;
width: 100%;
height: auto;
vertical-align: top;
padding: 4px;
box-sizing: border-box;
}
<p>
<img src="http://placehold.it/300x250">
<img src="http://placehold.it/300x300">
<img src="http://placehold.it/300x300">
<img src="http://placehold.it/300x250">
</p>
3 列中的 3 项(在 Chrome 中失败)
p{
-moz-column-count: 3;
column-count: 3;
-moz-column-gap: 0;
column-gap: 0;
-moz-column-fill: balance;
column-fill: balance;
outline:1px solid gray;
}
img{
display: inline-block;
width: 100%;
height: auto;
vertical-align: top;
padding: 4px;
box-sizing: border-box;
}
<p>
<img src="http://placehold.it/300x300">
<img src="http://placehold.it/300x300">
<img src="http://placehold.it/300x300">
</p>
【问题讨论】:
-
你的小提琴由于某种原因在我身上失败了,但是当我能够玩它时,我调整了
p元素的高度并且能够将它推到第三列,很奇怪的行为。一旦小提琴再次为我工作,我会继续寻找 -
列现在在 chrome 中是错误的。请阅读“已知问题”caniuse.com/#feat=multicolumn
-
在 Firefox 中发现了相同的行为。
-
您是否阅读了我编辑的答案并查看了包含的示例?解释就在那里……
-
@Johannes 感谢您的意见。是的,我已经检查了您的答案,但对于我的第二次 sn-p 来说,它并没有真正成立,对吧? 3 列中的 3 项 - 没有内容分布不均...见上文... 想法?此外,
column-fill: balance应该解决不均匀的项目拆分如此不均匀...
标签: html css css-multicolumn-layout