Guide to Scroll‑Driven Animations with CSS

June 26, 2025

Guide to Scroll‑Driven Animations with CSS

CSS animations can now be linked to user scrolling without any JavaScript — just pure CSS.

1. Three Parts of a Scroll‑Driven Animation

  • Target: the element you animate.
  • Keyframes: defines the animation steps.
  • Timeline: controls animation based on scroll/view, not time.

2. Using scroll() Timeline

Instead of time, the animation progress depends on the user scroll. Example:

footer::after {
  content: "";
  position: fixed;
  bottom: 0;
  left: 0;
  height: 1em;
  width: 100%;
  background: gold;
  animation: progress-expand;
  animation-timeline: scroll();
}

@keyframes progress-expand {
  from { width: 0%; }
  to { width: 100%; }
}

3. Accessibility Tip

Wrap animations with reduced‑motion preference check:

@media not (prefers-reduced-motion) {
  footer::after {
    animation: progress-expand;
    animation-timeline: scroll();
  }
}

4. Advanced: Custom Scroll/View Timelines

Use scroll(nearest block), named timelines, view(), animation-range, and timeline-scope to fine-tune behavior.

Scroll-driven animations now work natively in Safari 26 beta and Chrome 115+, offering smooth, hardware-accelerated UX.

The Ultimate Managed Hosting Platform