auto-fill combined with minmax() lets the grid figure out its own column count without a single media query.
<div style="display:grid;grid-template-columns:repeat(auto-fill,minmax(180px,1fr));gap:1rem"> <div style="background:#eee;padding:1rem;border-radius:8px">Card 1</div> <div style="background:#eee;padding:1rem;border-radius:8px">Card 2</div> <div style="background:#eee;padding:1rem;border-radius:8px">Card 3</div> </div>
auto-fill creates as many columns of at least 180px as fit in a row; 1fr stretches them evenly to fill the remaining space.
The simplest modern way to center a block using flexbox.