Grid fill empty cells

16 Replies
Wonderbear
Wonderbearβ€’4mo ago
Already tried grid-auto-flow: dense
MarkBoots
MarkBootsβ€’4mo 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β€’4mo ago
Please dont tell me I wasted hours :(
MarkBoots
MarkBootsβ€’4mo ago
im sorry mate there are js libs that can help with these "masonry" layouts
ghostmonkey
ghostmonkeyβ€’4mo 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β€’4mo ago
Do you have an example?
MarkBoots
MarkBootsβ€’4mo ago
im just looking at your example a bit more. are all the red cells 2 rows? and do they alternate?
Wonderbear
Wonderbearβ€’4mo ago
The red boxes are supposed to be 1fr higher than the green boxes What do you mean with 2 rows?
MarkBoots
MarkBootsβ€’4mo ago
the red ones are 2 rows
No description
MarkBoots
MarkBootsβ€’4mo ago
so yea, that's what i meant. maybe there is something possible here. need to think about it
Wonderbear
Wonderbearβ€’4mo ago
More like 1.1 rows
MarkBoots
MarkBootsβ€’4mo ago
yea that doesnt matter for now. im looking at the lines at the moment
Wonderbear
Wonderbearβ€’4mo ago
The masonry feature would fix everything instantly :(
MarkBoots
MarkBootsβ€’4mo ago
yep what kind of content is going into the boxes?
Wonderbear
Wonderbearβ€’4mo ago
Oh uhm I was trying to accomplish this challenge, so no content planned πŸ˜…
Jochem
Jochemβ€’4mo 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