Design comparison
Solution retrospective
Is there a basic rule when to use flex, when to use grid? Which properties are necessary to set for centering containers (width, width and height)?
Community feedback
- @akpekigPosted over 1 year ago
Generally, use whichever one requires less code. Flex is my personal go-to for items of the same size in repeating rows/columns (this requires about three lines of code with flex). Grid is my go-to when items are different sizes, asymmetrical, oddly spaced, etc. Grid lets you control this a lot easier than flex, which tends to rely on margins, orders, padding, fixed sizing and breakpoints to achieve the same result.
Depending on how you center a container, you may not need to set its size. Width is typically only necessary when using
margin: 0 auto
outside display flex.0@DvoraGPosted over 1 year ago@akpekig Thanks a lot, that is immensely clearing up some stuff in my head. Appreciate it very much!
0
Please log in to post a comment
Log in with GitHubJoin our Discord community
Join thousands of Frontend Mentor community members taking the challenges, sharing resources, helping each other, and chatting about all things front-end!
Join our Discord