Grid fill empty cells

16 Replies
Wonderbear
Wonderbear•9mo ago
Already tried grid-auto-flow: dense
MarkBoots
MarkBoots•9mo ago
unfortunatly not in css (at the moment), what you are looking for is a masonry grid, but that's not available (yet) for css grid. there is css columns that can create masonry-like layouts, but they are not able to span over multiple columns and the way they fill are from top to bottom, left to right
Wonderbear
Wonderbear•9mo ago
Please dont tell me I wasted hours :(
MarkBoots
MarkBoots•9mo ago
im sorry mate there are js libs that can help with these "masonry" layouts
ghostmonkey
ghostmonkey•9mo ago
I just completed a bento page with a similar issue, and what I ended up doing was the outer scaffolding in grid, and the inner stuff in flex, and assigned 100% height to the flex containers to fill all the space
Wonderbear
Wonderbear•9mo ago
Do you have an example?
MarkBoots
MarkBoots•9mo ago
im just looking at your example a bit more. are all the red cells 2 rows? and do they alternate?
Wonderbear
Wonderbear•9mo ago
The red boxes are supposed to be 1fr higher than the green boxes What do you mean with 2 rows?
MarkBoots
MarkBoots•9mo ago
the red ones are 2 rows
No description
MarkBoots
MarkBoots•9mo ago
so yea, that's what i meant. maybe there is something possible here. need to think about it
Wonderbear
Wonderbear•9mo ago
More like 1.1 rows
MarkBoots
MarkBoots•9mo ago
yea that doesnt matter for now. im looking at the lines at the moment
Wonderbear
Wonderbear•9mo ago
The masonry feature would fix everything instantly :(
MarkBoots
MarkBoots•9mo ago
yep what kind of content is going into the boxes?
Wonderbear
Wonderbear•9mo ago
Oh uhm I was trying to accomplish this challenge, so no content planned 😅
Jochem
Jochem•9mo ago
Actually, you can trick this kind of masonry layout with flex iirc, if you don't care about the order of your elements too much you set the direction to columns and turn on flex wrap iirc it'll run like this though
1 5 9
2 6 10
3 7 11
4 8 12
1 5 9
2 6 10
3 7 11
4 8 12
Want results from more Discord servers?
Add your server