← Demo hub

Container queries

Try: drag the lower-right corner of the dashed box to resize the container.

The card switches from stacked to horizontal when the container is wide enough—not when the viewport is.

Uses container-type: inline-size and @container card (min-width: 380px).

Inbox

Layout flips based on this box’s width, so the same component works in a sidebar or full column.

Source

<div class="viewport">
  <div class="card-wrap">
    <article class="card">…</article>
  </div>
</div>

.card-wrap {
  container-type: inline-size;
  container-name: card;
}
@container card (min-width: 380px) {
  .card {
    flex-direction: row;
    align-items: center;
  }
  .card h3 {
    font-size: 1.15rem;
  }
}
Support: Baseline-wide for size container queries (Chromium, Safari, Firefox). Subgrid is separate—this demo does not use it.