CSS

css/container-type-size

Query containers use container-type inline-size; size is only for elements that get their height from elsewhere.

umiarkowanastatycznefe-css-layout

Dlaczego

container-type: size applies size containment in both directions, so the element no longer grows with its content: without a height of its own it collapses to zero and its children overflow or vanish. Most component queries only need the width.

Poprawka

Use container-type: inline-size (or container: name / inline-size) to query width. Keep size for an element whose height is set independently (block-size, aspect-ratio, a grid track) when you really need height queries.

Przykłady

/* bad */
.card-list { container-type: size; }
/* good */
.card-list { container-type: inline-size; }
@container (width > 40rem) { .card { display: grid; grid-template-columns: 1fr 2fr; } }

Źródła

Fakty

Identyfikator
css/container-type-size
Waga
umiarkowana
Sprawdzanie
statyczne sprawdzane w kodzie źródłowym przez audit
Dotyczy plików
css scss less html vue svelte astro
Uczy jej skill
fe-css-layout CSS layout
Od wersji
0.1.0

Plik reguły na GitHubie

Przeczytaj w terminalu

npx github:dawidolko/frontend-skills explain css/container-type-size