I've run into a very odd behaviour regarding CSS column layout which only appears in Chrome.
Depending on the overall height of the item being columnized its left offset is shifted which makes it hard to determine an items actual location. The rendering looks fine but if you inspect the element you can actually see that it is offset by quite a alot.
Here's an example: https://jsfiddle.net/vx8h8u46/
Inspect the .panel element and you'll see that it's bounding rect does not start at the left.
If you click on the button to remove one item then all of the sudden the bounding rect is correct.
It appears that this happens when the panel's height exceeds a certain threshold but it's only speculation at this point. Is there a work around?
function logOffset() {
document.getElementById("log").innerText = document.querySelector(".panel").getBoundingClientRect().left;
}
window.removeLastItem = function() {
var items = document.querySelectorAll(".item");
if (items.length) {
items[items.length - 1].remove();
logOffset();
}
}
logOffset();
* {
box-sizing: border-box;
}
.item {
display: inline-block;
width: 160px;
height: 80px;
outline: 1px solid red;
}
.container {
-moz-column-width: 320px;
column-width: 320px;
-moz-column-fill: auto;
column-fill: auto;
max-height: 160px;
width: 640px;
}
<div class="container">
<div class="panel">
<div class="item">1</div>
<div class="item">2</div>
<div class="item">3</div>
<div class="item">4</div>
<div class="item">5</div>
<div class="item">6</div>
<div class="item">7</div>
<div class="item">8</div>
<div class="item">9</div>
<!-- Something weird happens after this -->
<div class="item">10</div>
</div>
</div>
<div>
Left offset of
<mark>panel</mark>:
<span id="log"></span>
</div>
<button onclick="removeLastItem()">
Remove last item
</button>
display: inline
to.panel
, it does fix the problem. If that's what you mean, make it clear in your answer and consider adding an example snippet. – Impoverished