When to use neither Grid nor Flexbox?

I'm a frontend newbie. I read how CSS Grid and Flexbox are the future and replace most legacy CSS hacks. So, in which situations should I use neither display: grid nor display: flex when laying out children items of an element? Or can I just slap one or the other on everything to reduce the amount of fighting with CSS?
12 Replies
MarkBoots
MarkBootsā€¢13mo ago
well, if you have a single column layout, you'll probably don't need either, else it surely helps
kangalio
kangalioā€¢13mo ago
Hmm
kangalio
kangalioā€¢13mo ago
For example I started to implement this layout yesterday (from icodethis.com) (didnt get very far)
No description
kangalio
kangalioā€¢13mo ago
what if i just slapped nested CSS grids on everything like this
No description
kangalio
kangalioā€¢13mo ago
(every color is a separate grid; dotted lines indicate where elements span across a grid line) is that a viable strategy? (very much doesnt feel like it šŸ˜…)
MarkBoots
MarkBootsā€¢13mo ago
yea it could be. there is not really a right or wrong here.
kangalio
kangalioā€¢13mo ago
damn
there is not really a right or wrong here.
I try to go as close as possible to the way the spec designers intended CSS to be used to minimize me fighting against the challenge so I'd love to know how "everyone else" does it it's my experience from every other programming area that staying close to the way a library or framework is meant to be used tends to make things magically work
Jochem
Jochemā€¢13mo ago
with CSS, there's usually multiple equally valid ways of solving a problem take a look at Kevin's most recent video where he goes through the layout challenge solutions, lots of different ways to do the same thing. Over time, you'll develop favorites and learn pros and cons, but that's not really the kind of knowledge someone can summarize in a post on Discord šŸ™‚
kangalio
kangalioā€¢13mo ago
yeah thats how i got onto this server, and where i got the motivation to implement random layouts ^^ okay.. thanks for the answers btw! :) but for example in kevin's latest video, flexbox would have been the suboptimal way to go about the problem, and doing it anyways entailed fighting against the language (that margin-left: <magic number> thing, or having to restructure HTML to get white space where you want it) But I suppose you're saying, knowing which tool is right for the job can only be learned the hard way through experience?
Jochem
Jochemā€¢13mo ago
I can't give you a hard and fast set of rules that always give you the same answer at least like Mark said though, there's not that many situations where either flex or grid isn't a good solution
kangalio
kangalioā€¢13mo ago
okay thank you both @Jochem @MarkBoots! šŸ¤—
clevermissfox
clevermissfoxā€¢13mo ago
I did this icodethis challenge myself and think I used a combination of grid and flexbox as Iā€™m still not super confident with keeping grid responsive and fitting the content without leftover space
Want results from more Discord servers?
Add your server