CSS
css/rem-units
Font sizes are written in rem (or em), never px, in projects without a rem helper; with one, css/rem-helper applies.
drobnastatycznefe-css-architecture
Dlaczego
A px font size ignores the text size the person set in their browser, so text that is comfortable for the designer stays small for someone who needs it larger. Browser zoom still works, but the text-size setting is how many people with low vision read every site.
Poprawka
Write font sizes in rem (or em inside a component that should follow its parent): 16px is 1rem at the default size. Fluid sizes keep rem bounds: clamp(1rem, 0.9rem + 0.5vw, 1.25rem). When the profile records a px-to-rem function (helper rem-function, for example Foundation's rem-calc()), this rule steps aside and css/rem-helper asks for that function instead; with a build step that converts px (px-to-rem-build) px in the source is the convention.
Przykłady
/* bad */
.card__title { font-size: 20px; }
/* good */
.card__title { font-size: 1.25rem; }Źródła
Fakty
- Identyfikator
css/rem-units- Waga
- drobna
- Sprawdzanie
- statyczne sprawdzane w kodzie źródłowym przez
audit - Dotyczy plików
cssscsslesshtmlvuesvelteastro- Uczy jej skill
fe-css-architectureCSS architecture and tokens- Od wersji
- 0.1.0
Przeczytaj w terminalu
npx github:dawidolko/frontend-skills explain css/rem-units