Looking for a way to dynamically adjust div sizes based on available space within the parent container to minimize white space. Hoping for a solution that can accommodate fluctuations in the number of divs over time.
The goal is to reduce white space as much as possible, even if it means using vertical scrolling. While I've experimented with a script that provided some progress, I believe there might be a more effective approach leveraging CSS grids auto-sizing capabilities:
if (size.width > size.height && divCount.length < 13) {
columnSize = Math.round(12 / (divCount.length / 2));
}
if (size.width < size.height && divCount.length < 13) {
columnSize = 6;
}
let colClass = 'col-6 col-sm-4 col-md-' + columnSize;
https://i.sstatic.net/iMP6L.png I have provided a starter file, but I apologize for the lack of code - I'm uncertain where to start: https://codepen.io/liamb/pen/KKVqvdz