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
3 Replies
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:
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.
grid has the advantage that you can use subgrid within the cards