【发布时间】:2018-03-16 06:10:03
【问题描述】:
问题
使用 CSS column-property 在页面上创建列我注意到布局引擎的一些奇怪行为。也就是说,我正在使用
body {
padding: 0;
background-color: black;
margin: 0;
column-width: 308px;
column-gap: 0;
column-rule: none;
line-height: 0;
}
因此每列的宽度应为 308 像素。我的演示页面看起来非常正常,除了以大约 2400 像素宽度查看时。然后它看起来像这样:
请注意最后一列中的大黑区。我的数学告诉我 2400 / 308 = 7.79 > 7。人们会期望在 2400px 视口宽度处出现七列。然而,布局引擎只使用了六个。这种行为在 chrome 和 firefox 之间是一致的,甚至在将 column-width: 308px 替换为 column-count: 7 时仍然存在。
问题
我想知道是什么导致浏览器在这个宽度处忽略第 7 列。有没有办法避免这种行为?
代码
可以使用以下来源或this fiddle 重现该问题
body {
padding: 0;
background-color: black;
margin: 0;
column-width: 308px;
column-gap: 0;
column-rule: none;
line-height: 0;
}
img {
margin: 12px;
padding: 9px;
border: 1px solid darkgrey;
background-color: white;
display: inline-block;
width: 264px;
}
.w {
height: 176px;
}
.h {
height: 396px;
}
<img class="w">
<img class="w">
<img class="h">
<img class="w">
<img class="w">
<img class="w">
<img class="w">
<img class="w">
<img class="w">
<img class="h">
<img class="w">
<img class="w">
<img class="w">
<img class="w">
<img class="h">
<img class="w">
<img class="w">
<img class="h">
<img class="w">
<img class="w">
<img class="w">
<img class="w">
<img class="w">
<img class="w">
<img class="h">
<img class="w">
<img class="w">
<img class="w">
<img class="w">
<img class="h">
【问题讨论】:
-
对我来说它恰好发生在 2445px 之后
标签: html css column-width css-multicolumn-layout column-count