The Problem
Using the CSS column
-property to create columns on a page I am noticing some weird behavior of the layouting engine. Namely, I am using
body {
padding: 0;
background-color: black;
margin: 0;
column-width: 308px;
column-gap: 0;
column-rule: none;
line-height: 0;
}
So that every column should be 308px wide. My demo page looks perfectly normal, except for when viewed at about 2400px width. Then it looks like this:
Note the large black space in the very last column. My math tells me 2400 / 308 = 7.79 > 7. One would expect seven columns to be present at 2400px viewport width. However only six are used by the layouting engine. This behavior is consistent between chrome and firefox and even persists, when replacing column-width: 308px
with column-count: 7
.
The Question
I would like to know what causes the browser to ignore the 7th column at exactly this width. Is there a way to avoid this behavior?
The Code
The problem can be reproduced using the following source or 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">