whoscatrevival/public/stylesheets/cats.js
2022-01-03 20:56:33 +11:00

9 lines
357 B
JavaScript

const numCols = 3;
const colHeights = Array(numCols).fill(0);
const container = document.getElementById('masonry-with-columns');
Array.from(container.children).forEach((child, i) => {
const order = i % numCols;
child.style.order = order;
colHeights[order] += parseFloat(child.clientHeight);
})
container.style.height = Math.max(...colHeights) + 'px';