Container queries

Style a component by the width of its own box instead of the whole screen, so the same card works in a sidebar and in a wide column. Supported by current browsers.

CSS · Container queriesAdvanced
.card-wrap { container-type: inline-size; }

.card { display: block; }

@container (min-width: 480px) {
  .card { display: grid; grid-template-columns: 160px 1fr; gap: 1rem; }
}
container querycomponentsresponsive