CSS
css/no-fixed-height-text
Boxes that hold text do not combine a fixed height with hidden overflow; use min-height so enlarged or spaced text is not clipped.
poważnastatyczneWCAG 1.4.4, 1.4.12 · AAfe-css-layout
Dlaczego
A box of height: 72px; overflow: hidden fits the text only at the designer's font size, line height and language. When someone enlarges text, raises line or letter spacing, or the copy is translated into a longer language, the end of the text is cut off without a trace.
Poprawka
Use min-height (or min-block-size) and padding, and let the content decide the height. To shorten long text on purpose, use line-clamp with a way to read the rest. Fixed sizes are fine for media and for boxes whose width is fixed too (avatars, icon buttons). Check by applying the WCAG text-spacing values (line height 1.5, letter spacing 0.12em, word spacing 0.16em, paragraph spacing 2em).
Przykłady
/* bad */
.card__excerpt { height: 72px; overflow: hidden; }
/* good */
.card__excerpt { min-height: 4.5rem; }Źródła
Fakty
- Identyfikator
css/no-fixed-height-text- Waga
- poważna
- Sprawdzanie
- statyczne sprawdzane w kodzie źródłowym przez
audit - Dotyczy plików
cssscsslesshtmlvuesvelteastro- WCAG 2.2
- 1.4.4, 1.4.12, poziom AA
- Uczy jej skill
fe-css-layoutCSS layout- Od wersji
- 0.1.0
Przeczytaj w terminalu
npx github:dawidolko/frontend-skills explain css/no-fixed-height-text