Прескочи на главни садржај
← 🎨 CSS as a design system·Модул B3 · Лекција 7
ЗадатакBuild a 2-column grid where the first column is between 200px and 280px and the second column is the remainder. .grid: display: grid, grid-template-columns: minmax(200px, 280px) 1fr, gap: 12px. Two .cell divs.

минмак(): подови и плафони за стазе

75 XP6 min
Теорија

Constrain a track between two sizes

grid-template-columns: minmax(200px, 1fr) minmax(0, 600px);

Each minmax(min, max) track stays between those bounds. Reads as: "this column is AT LEAST min, AT MOST max, otherwise as big as it wants."

Common uses

/* Sidebar that won't shrink below 200px even when window is narrow */
grid-template-columns: minmax(200px, 240px) 1fr;

/* Main that grows but caps at 800px for readability */
grid-template-columns: 240px minmax(0, 800px);

/* All columns at least 280px, max 1fr (fill but never below 280) */
grid-template-columns: repeat(3, minmax(280px, 1fr));

The minmax(0, 1fr) trick

Sometimes a grid item's content forces it WIDER than 1fr should be (e.g. a very long unbreakable URL). To make the column truly elastic regardless of content:

grid-template-columns: 1fr minmax(0, 1fr);

minmax(0, 1fr) says "minimum is 0, so the content can't force you wider." Critical when grid children contain long text or overflow-x content.

🔒

Региструј се да почнеш са кодом

Теорија је отворена за све. Едитор, преглед уживо и провера се откључавају са 7-дневним бесплатним пробним периодом — потребна картица.

Регистрација — бесплатан пробни период →

Првих 10 лекција у сваком путу су бесплатне. Без картице.

← ПретходнаСледећа лекција →

Један савет за Python или веб дневно — на имејл

Кратко, ручно писано, без спама. Одјава у једном клику.