Creating a masonry layout with CSS only (tobiasahlin.com)
almost 4 years ago from Tobias Ahlin
almost 4 years ago from Tobias Ahlin
That was neat
Isn't this type of layout extremely trivial with grid? Wondering why they chose to recreate this with flexbox.
Do you have any good tutorials on doing this with grid? I tried awhile ago to understand it but just couldn't get it.
Here's a pretty simple example: https://codepen.io/balazs_sziklai/pen/mOwoLg
Thanks!
While grid is awesome, that codepen example is not fallowing a truly a masonry style, it should be more like Pinterest where you don't know how tall are the items beneath them cover the free space that shorter ones leave. With grid creating rows it will leave spaces or you have to stretch the items to the same height. Just different styles, I think the masonry flex solution from Tobias will work great for a feed or waterfall of content.
To echo Ramiro. True masonry should work regardless of a tiles height (it should respond dynamically to height). Grid does not allow for that. You have to know the height of the tiles before hand, which does not work well for dynamically populated content.
Designer News
Where the design community meets.
Designer News is a large, global community of people working or interested in design and technology.
Have feedback?
Login to Comment
You'll need to log in before you can leave a comment.
LoginRegister Today
New accounts can leave comments immediately, and gain full permissions after one week.
Register now