+ 1

Why use flex and not grid?

I'm learning how to work with display: grid at the moment and I'm pretty close to finish it, and from what I have learned so far grid can basically do everything flex can do, but also can do a bunch of other useful stuff, so I'm wondering, why would I ever prefer flex over grid? Is there anything I have missed?

9th Aug 2020, 12:04 PM
Karak10
Karak10 - avatar
3 Respuestas
+ 6
- Flex has more support. IE supports it. - Flex is easier to use for one-dimensional components. - Flex is easier to understand by beginners - Flex gives you more flexibility on the position of individual items. This are just possible reasons to use flex. There are many more reasons to use grid. I don't prefer one over the other. I use both when I deem fit.
9th Aug 2020, 12:17 PM
Ore
Ore - avatar
+ 3
KINGDX Before flex and grid, we created grids and flexible boxes with css hacks and antipatterns. Similarly, flex can be used to create 2D-ish layouts but it is not so easy, neither is it efficient. For full page layouts or other grid-like layouts it is better to use grid unless you are worried about support.
9th Aug 2020, 12:36 PM
Ore
Ore - avatar
+ 2
I honestly never really used CSS grids so I can't offer a good comparison between the two, but nowadays I primarily use flex for its ability to easily center things vertically on top of doing all the other alignments. I have never came across a case that flexbox doesn't have a solution to tbh.
9th Aug 2020, 12:21 PM
CHMD
CHMD - avatar