DEV Community

Discussion on: When to use CSS Grid and when to use Flexbox for Multiline Layout

Collapse
 
dbshanks profile image
Derek Shanks

Great article. Many are unaware how well Grid and FlexBox can work well together.

My strategy: FlexBox for Navigation and informational Footer, I always use Flex on containers that are being iterated or dynamically updated, the wrap feature is gold to ensure sanity when new line starts.

It's Grid for everything else that I need to ensure that a container doesn't surprise me in the browser. Haha!

Collapse
 
mpuckett profile image
Michael Puckett

That's a great example of where flexbox shines! Throw a bunch of stuff at it and let it find the best fit. Flex layout is a constraint system, which is great to be able to dip into, but the layout logic can certainly cause surprises. Grid to me feels like building with brick and mortar, much more predictable. We're very lucky to finally have both at our disposal!

🤘