Card grid

카드 그리드

The practical pattern behind most card grids: repeat(auto-fit, minmax(…)) decides the column count itself, no fixed card count required.

Also known as: Responsive card gridauto-fit card layout
···
html
<div class="stage" id="stage">
  <div class="cards">
    <div class="card"><i class="ic"></i><b class="t"></b><i class="ln"></i></div>
    <div class="card"><i class="ic"></i><b class="t"></b><i class="ln"></i></div>
    <div class="card"><i class="ic"></i><b class="t"></b><i class="ln"></i></div>
    <div class="card"><i class="ic"></i><b class="t"></b><i class="ln"></i></div>
  </div>
</div>
css
.stage{width:40%;min-width:210px;max-width:92%;border:2px dashed var(--muted);border-radius:10px;padding:10px;
  transition:width 2.8s cubic-bezier(.4,0,.2,1);box-sizing:border-box}
.stage.wide{width:92%}
.cards{display:grid;grid-template-columns:repeat(auto-fit,minmax(84px,1fr));gap:8px}
.card{background:var(--surface);border:1px solid var(--line);border-radius:8px;padding:8%;display:flex;
  flex-direction:column;gap:8px;align-items:flex-start}
.ic{width:26%;aspect-ratio:1;border-radius:6px;background:var(--accent)}
.t{display:block;width:70%;height:7px;border-radius:3px;background:var(--fg);opacity:.7}
.ln{display:block;width:85%;height:6px;border-radius:3px;background:var(--line)}
js
const stage = document.getElementById('stage');
setInterval(() => stage.classList.toggle('wide'), 2400);

grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)) is the most common real-world use of the mechanism explained in the auto-fill-vs-auto-fit entry. minmax(140px, 1fr) means "each card is at least 140px, and whatever space is left gets shared evenly"; auto-fit works out on its own how many cards fit as the screen widens — no need to hand-write "3 columns at this width, 4 at that one" in a media query.

The minmax minimum is the actual design knob for a card grid. Raise it (say to 220px) and the same screen width fits fewer, bigger columns; lower it (say to 100px) and more columns pack in tighter. Replacing the maximum's 1fr with a fixed pixel value caps how wide a card is allowed to grow.

The pattern's limit is that it doesn't equalize card height on its own — cards in the same row do get stretched to match thanks to grid's default align-items: stretch, but wildly different content lengths can still look uneven. Line-clamp the text inside each card to a fixed number of lines, or switch to masonry entirely if the heights genuinely need to vary.

When to use

The near-default choice for content with a variable item count and roughly uniform card sizes — blog post lists, product listings, team member grids.