Preskoči na glavni sadržaj
← 🎨 CSS as a design system·Modul B3 · Lekcija 11
ZadatakBuild a label + input grid. .form: display: grid, grid-template-columns: max-content 1fr, gap: 8px 16px. Inside: 3 pairs of <label> + <input>. Labels are 'Email', 'Password', 'Confirm password'.

Unutarnje dimenzioniranje: min. sadržaj, maks. sadržaj, auto

75 XP6 min
Teorija

Sizes based on content, not pixels

CSS Grid offers three "intrinsic" track sizes:

grid-template-columns: min-content 1fr max-content;
  • `min-content` — the smallest size where the content doesn't overflow. For text: the width of the LONGEST WORD.
  • `max-content` — the size where the content uses no line breaks. For text: the width of the FULL UN-WRAPPED line.
  • `auto` — the browser picks something reasonable based on content + available space.

When each is useful

/* Label column sized to its widest label, value column gets the rest */
.form-grid { grid-template-columns: max-content 1fr; }

/* "As narrow as possible" sidebar */
.nav { grid-template-columns: min-content 1fr; }

For form-style layouts, max-content 1fr is the perfect "label + input" recipe.

fit-content() — clamp intrinsic sizing

grid-template-columns: fit-content(200px) 1fr;

The first column is sized to its content, but capped at 200px. Above 200px it wraps. Useful for "as wide as content, but not absurd."

🔒

Registriraj se i počni kodirati

Teorija je otvorena svima. Editor, pregled uživo i provjera otključavaju se s 7-dnevnim besplatnim probnim periodom — potrebna kartica, otkaži kad god.

Registracija — besplatan probni period →

Prvih 10 lekcija u svakom smjeru je besplatno. Bez kartice.

← PrethodnaSljedeća lekcija →

Jedan Python ili web savjet dnevno — emailom

Kratko, ručno pisano, bez spama. Odjavi se jednim klikom.