Прескочи на главни садржај
← 🎨 CSS as a design system·Модул B7 · Лекција 3
ЗадатакBuild two cards. .card-bad uses transition: left; .card-good uses transition: transform. Both move 100px on hover. .card-bad uses position: relative; left: 0 → left: 100px. .card-good uses transform: translateX(0) → translateX(100px). Demo the difference.

Својства само за композитор: трансформација, непрозирност, филтер

100 XP7 min
Теорија

Why some animations feel buttery, others jank

Browser rendering pipeline: Layout → Paint → Composite. Most CSS property changes trigger Layout (expensive). A few only run on the GPU's compositor (cheap).

Cheap (60fps even on phones):

  • transform — translateX/Y, rotate, scale, skew.
  • opacity — fade in/out.
  • filter — blur, brightness, hue-rotate.

Expensive (drops below 60fps on phones):

  • width, height, margin, padding — triggers layout.
  • top, left, right, bottom — triggers layout.
  • box-shadow — triggers repaint.
  • background-color — repaint (lighter than layout, still costs).

The rule

/* BAD — left triggers layout on every frame */
.slide { left: 0; transition: left 0.3s; }
.slide:hover { left: 100px; }

/* GOOD — translateX runs on the compositor */
.slide { transform: translateX(0); transition: transform 0.3s; }
.slide:hover { transform: translateX(100px); }

ANY property that can be expressed as a transform should be — the visual result is identical but the performance is 10× better on mobile.

will-change

.modal { will-change: transform, opacity; }

Hint to the browser: "promote this to its own GPU layer now." Use SPARINGLY — applying to many elements wastes memory. Best practice: add will-change only just BEFORE animating, remove after.

🔒

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

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

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

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

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

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

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