← CodeClarityLab Home
Browse by Category
+ added · updated 7d
← Back to glossary

CSS Animations & Transitions

frontend CSS3 Intermediate
debt(d5/e3/b3/t5)
d5 Detectability Operational debt — how invisible misuse is to your safety net

Closest to 'specialist tool catches' (d5). Lighthouse and Chrome DevTools (from detection_hints.tools) can identify layout thrashing and animation performance issues through Performance panel recordings and Lighthouse audits, but these require deliberate profiling — the jank isn't caught by default linters or build-time checks.

e3 Effort Remediation debt — work required to fix once spotted

Closest to 'simple parameterised fix' (e3). The quick_fix shows a pattern replacement: swap width/height animations for transform: scale(), swap left/top for transform: translate(). This is a targeted refactor within CSS files, not a single-line fix but also not cross-cutting architectural work.

b3 Burden Structural debt — long-term weight of choosing wrong

Closest to 'localised tax' (b3). Animation choices affect specific components' CSS rather than the entire codebase. Poor animation patterns cause local performance issues but don't impose system-wide constraints — you can fix one component's animations without touching others. The reach is limited to frontend presentation layer.

t5 Trap Cognitive debt — how counter-intuitive correct behaviour is

Closest to 'notable trap' (t5). The misconception states developers believe 'all CSS animations are hardware-accelerated' when only transform and opacity use GPU compositing. This is a documented gotcha that most frontend developers eventually learn through performance debugging, but it's not immediately obvious from CSS syntax that animating 'width' behaves fundamentally differently from animating 'transform'.

About DEBT scoring →

Also Known As

CSS transition keyframe animation will-change 60fps

TL;DR

CSS transitions animate property changes smoothly; keyframe animations define multi-step sequences — both should use GPU-composited properties (transform, opacity) for smooth 60fps.

Explanation

CSS transitions: transition: property duration easing — animate between two states on event. Keyframe animations: @keyframes + animation property — define multi-step sequences that play automatically. For performance, only animate properties that the browser can composite on the GPU without triggering layout: transform (translate, scale, rotate) and opacity. Animating width, height, top, left, or color triggers layout/paint, causing jank. Use will-change: transform as a hint for complex animations. prefers-reduced-motion media query should disable or reduce animations for users who request it.

Diagram

flowchart LR
    subgraph GPU Composited - Smooth 60fps
        T[transform: translate scale rotate]
        O[opacity]
        T & O --> GPU[GPU thread<br/>no layout recalc]
    end
    subgraph CPU - Causes Jank
        W[width height top left]
        BG[background-color]
        W & BG --> CPU[Main thread<br/>layout + paint every frame]
    end
    style GPU fill:#238636,color:#fff
    style CPU fill:#f85149,color:#fff

Common Misconception

All CSS animations are hardware-accelerated — only transform and opacity are composited by the GPU; animating width, height, or background-color triggers expensive layout recalculation.

Why It Matters

Animating the wrong CSS properties causes layout thrashing and dropped frames — a smooth animation uses transform, a janky one animates width or top.

Common Mistakes

  • Animating width/height for expand effects — use transform: scaleY() instead.
  • Animating left/top for movement — use transform: translateX/Y() instead.
  • Not respecting prefers-reduced-motion — vestibular disorders make animations cause physical discomfort.
  • will-change on every element — hints consume GPU memory; use only on elements with complex animations.

Code Examples

✗ Vulnerable
/* Janky — triggers layout on every frame:
.box {
    transition: width 0.3s, left 0.3s; /* Layout properties — CPU bound */
}
.box:hover {
    width: 200px;  /* Forces layout recalculation */
    left: 100px;   /* Forces layout recalculation */
}
✓ Fixed
/* Smooth — GPU composited:
.box {
    transition: transform 0.3s ease, opacity 0.3s ease;
    will-change: transform; /* Hint for complex cases only */
}
.box:hover {
    transform: translateX(100px) scaleX(1.5); /* GPU only, no layout */
}

/* Respect reduced motion:
@media (prefers-reduced-motion: reduce) {
    .box { transition: none; }
}

Added 15 Mar 2026
Edited 22 Mar 2026
Views 23
Rate this term
No ratings yet
🤖 AI Guestbook educational data only
| |
Last 30 days
0 pings F 0 pings S 2 pings S 1 ping M 0 pings T 0 pings W 0 pings T 0 pings F 0 pings S 1 ping S 0 pings M 0 pings T 0 pings W 3 pings T 0 pings F 0 pings S 2 pings S 0 pings M 0 pings T 1 ping W 0 pings T 0 pings F 0 pings S 1 ping S 0 pings M 0 pings T 0 pings W 0 pings T 0 pings F 0 pings S
No pings yet today
No pings yesterday
Amazonbot 8 Perplexity 5 Google 2 Ahrefs 2 Unknown AI 2 ChatGPT 2
crawler 19 crawler_json 2
DEV INTEL Tools & Severity
🟡 Medium ⚙ Fix effort: Medium
⚡ Quick Fix
Animate only transform and opacity — they run on the GPU compositor thread without triggering layout reflow; add will-change: transform only when animating
📦 Applies To
css CSS3 web
🔗 Prerequisites
🔍 Detection Hints
Animating width height top left margin — triggers layout reflow jank; animation without prefers-reduced-motion check
Auto-detectable: ✓ Yes lighthouse chrome-devtools
⚠ Related Problems
🤖 AI Agent
Confidence: Low False Positives: High ✗ Manual fix Fix: Medium Context: File

✓ schema.org compliant