Responsywność

responsive/no-fixed-wide-width

No layout box gets a fixed width wider than 320 CSS px; cap it with max-width or min(100%, …) so the page reflows on narrow screens.

poważnastatyczneWCAG 1.4.10 · AAfe-responsive

Dlaczego

A box with width: 960px or min-width: 500px stays that wide on a phone and at 400% zoom (a 1280px window zoomed four times is 320 CSS px), so every line has to be scrolled sideways to be read. Reflow (WCAG 1.4.10) asks that content fits 320 CSS px without two-dimensional scrolling, apart from things like data tables and maps.

Poprawka

Use max-width for the limit and let the box shrink: max-width: 60rem; margin-inline: auto, or width: min(100%, 40rem). Put a wide fixed size inside a @media (min-width: …) or @container query where there is room. Data tables and code blocks scroll inside their own wrapper.

Przykłady

/* bad */
.wrapper { width: 960px; }
/* good */
.wrapper { max-width: 60rem; margin-inline: auto; padding-inline: 1rem; }

Źródła

Fakty

Identyfikator
responsive/no-fixed-wide-width
Waga
poważna
Sprawdzanie
statyczne sprawdzane w kodzie źródłowym przez audit
Dotyczy plików
css scss less html vue svelte astro
WCAG 2.2
1.4.10, poziom AA
Uczy jej skill
fe-responsive Responsive design
Od wersji
0.1.0

Plik reguły na GitHubie

Przeczytaj w terminalu

npx github:dawidolko/frontend-skills explain responsive/no-fixed-wide-width