Flex or Grid for cards?

Hey, i'm building a CSS project with cards, i'm really confused if we should use flex or grid for these cards. I'm preferring grid as it won't shrink the sizes of these cards at all, and they'll offer a structure from the parent. However I'm Worried about responsiveness, should I use a breakpoint then? or do you guys have other suggestions
No description
3 Replies
ZNP
ZNP3mo ago
No description
Chris Bolson
Chris Bolson3mo ago
As you say, you can use breakpoints to define the number of columns. If you want a slightly more "flexible" approach, but still using grid, you can use something like this:
grid-template-columns: repeat(auto-fit,minmax(300px,1fr));
grid-template-columns: repeat(auto-fit,minmax(300px,1fr));
This method will attempt to fit as many cells as it can on the row, having a minimum width of 300px (or whatever you consider to be the best minimum value for each of your "cards". As soon as the cards would become narrower than 300px it will move them to the next row. and re-calculate the widths to fit them within the available space, whilst maintaining the grid.
Martin Beroiz
Martin Beroiz3mo ago
grid has the advantage that you can use subgrid within the cards
Want results from more Discord servers?
Add your server