Responsive cards and auto-fit, auto-fill

Short question, and it might not have a straight forward answer. But here we go ... In this codepen I'm testing all things responsive, and the goal is to avoid using @media. As Kevin has pointed out in several videos, there should only be need to add complexitiy if necessary. https://codepen.io/amarlong/pen/LYrmpNO So my cards are controlled with auto-fit, and between view width 1280px and 960px the four cards stack out with three on top and one underneath. Is there anyway to force them to do a two over two (without @media) between that pixel range, or is this a limitation of auto-fit/fill?
6 Replies
MarkBoots
MarkBoots3y ago
no i don't think there is a way to wrap them by two at a time. it will allways try to fill the row first and only creates a new row when a grid item doesnt fit anymore.
Å Marlon G
Å Marlon GOP3y ago
Just tried with clamp() as well, but guess that's not a function that grid-template-columns will use. So the follow up question is: How can I achieve it most elegantly without @media?
MarkBoots
MarkBoots3y ago
What is the reason you don't want to use media queries?
Å Marlon G
Å Marlon GOP3y ago
No other reason then to try and see if it's possible without it. In terms of Kevin's mantra of not adding complexity if not needed, and adding a @media feels like adding something extra. But if it's not possible, then of course, @media it is then.
MarkBoots
MarkBoots3y ago
if it is possible it would create a lot more complexity. a media query in this scenario is the way to go
Å Marlon G
Å Marlon GOP3y ago
Give and take, I guess. Thank you again!
Want results from more Discord servers?
Add your server