Перейти до основного вмісту
← 🎨 CSS as a design system·Модуль B5 · Урок 8
ЗавданняBuild a hero with a vibrant gradient. .hero has background linear-gradient(in oklch 135deg, oklch(0.66 0.18 252), oklch(0.66 0.18 320)). min-height 200px, color white, padding 24px, font-family system-ui sans-serif.

Градієнти 2026: інтерполяція oklch

75 XP6 min
Теорія

The "muddy middle" problem (and its fix)

.old { background: linear-gradient(to right, blue, yellow); }

In sRGB, blue→yellow goes through MUDDY GRAY in the middle. Because the math averages RGB channels and "blue + yellow = somewhere brown."

.modern { background: linear-gradient(in oklch to right, blue, yellow); }

in oklch tells the browser to interpolate in OKLCH space. The middle stays vibrant. Looks like a smooth rainbow instead of muddy mush.

Other color spaces

linear-gradient(in srgb,           ...);
linear-gradient(in hsl shorter hue, ...);  /* hue takes the shorter angular path */
linear-gradient(in hsl longer hue,  ...);  /* takes the long way around */
linear-gradient(in oklch,           ...);
linear-gradient(in lab,             ...);

For most "color A to color B" gradients, in oklch is the safe modern default.

Conic gradients

background: conic-gradient(in oklch from 90deg, red, yellow, green, cyan, blue, magenta, red);

Same color-space rules apply to radial-gradient and conic-gradient.

Hard stops

background: linear-gradient(to right, blue 0% 50%, yellow 50% 100%);

color 0% 50% means "this color from 0% to 50% with no transition" — creates a sharp boundary. Useful for stripe patterns or two-tone backgrounds.

🔒

Зареєструйся щоб кодувати

Теорія відкрита всім. Інтерактивний редактор, живий перегляд і перевірка відкриваються з 7-денним безкоштовним trial — потрібна картка, скасування у будь-який час.

Реєстрація — безкоштовний trial →

Перші 10 уроків у кожному треку — безкоштовні. Картка не потрібна.

← НазадНаступний урок →

Отримуй одну пораду з Python чи вебу — щодня поштою

Коротко, без води, без спаму. Відписка — в один клік.