Thanks I ususally default to Flex because is what I know better, I have to fill the gaps with grid knowledge in there.
Re:CSS Findings from the Threads App
by laurels-marts on Sunday July 16, 2023 @09:14AM
(#36746649)
Maybe a stupid question but what do you use for the outermost wrapper div that controls the main page layout? Flex or Grid?
Re:CSS Findings from the Threads App
by ThatMedicIsASpy on Sunday July 16, 2023 @11:47AM
(#36748317)
Depends on the content and amount of content. I would say you can do the same layout with both. The main advantage of grid and named layouts is that you can move them anywhere you want. You are not bound by the order of html elements.
Yeah, it varies. Sometimes gris, sometimes flex.
I love grid because it allow me to position elements anywhere in the grid without needing wrapper elements like with flex/float. That allow nearly full freedom in layouting the same HTML for different complex layouts targeting different screen width.
Though while grid borrowed a lot of ideas from flex, the creative usage of the grid template is so vast that you probably need to also learn by examples.
So I expect that what you are mostly seeing is the evolution of CSS, from table to flexbox to grid. Table has no real responsiveness (to screen size), Flex does it _really_ well (especially for cases where the target is both PC and Phone etc.) But it has some limitations (mostly for me around column widths and the concept of "relative" column widths.)
Grid is really nice, it's a lot more like tables in concept, but at the same time has responsive abilities. These days I'm grid-first, although there are still a few places (depending on context) where flex is more appropriate.
Of course flex is also more "well known" (because it's older.) I feel a lot more comfortable there still, and until we have sub-grids I'm also a fan of using Grid layout for the "outside" and using Flex inside specific cells.