Skip to content
Tutorials Center
My learning

Topics

CSS Reference ยท Transforms, Transitions and Animations

The animation-timeline property

Reference for the CSS animation-timeline property: drive an animation by scroll position or element visibility with scroll(), view() or a named timeline.

The animation-timeline property chooses what drives an animation's progress. By default that is time: the animation advances as the clock ticks. With a scroll or view timeline, progress follows how far a container has been scrolled, or how far an element has travelled through the visible area. This is the basis of scroll-driven animations.

You can pass an anonymous timeline with scroll() or view(), or the name of a timeline declared with scroll-timeline or view-timeline.

CSS
.progress {
  animation: grow linear both;
  animation-timeline: scroll();
}

Try it

Reading progress bar
Reveal on view

Syntax

CSS
animation-timeline: auto | none | <dashed-ident> | scroll() | view();

scroll( [ nearest | root | self ] || [ block | inline | x | y ] )
view( [ block | inline | x | y ] || <'view-timeline-inset'> )

/* one value per animation name */
animation-timeline: scroll(root), view();
  • Initial value: auto
  • Applies to: all elements, ::before and ::after
  • Inherited: no
  • Animatable: no
  • Computed value: as specified

Values

Value Description
auto The default document timeline: time drives the animation.
none No timeline, so the animation does not run.
<dashed-ident> The name of a timeline from scroll-timeline or view-timeline on this element or an ancestor (names start with --).
scroll() An anonymous scroll progress timeline. The first keyword picks the scroller (nearest ancestor scroll container by default, root for the page, self). The second picks the axis (block by default, inline, x or y).
view() An anonymous view progress timeline for this element in its nearest scroll container. Takes an optional axis and inset.

Usage notes

  • Declare the timeline after the animation shorthand. The shorthand resets animation-timeline to auto, so a timeline set earlier would be lost.
  • Use linear easing. Scroll progress should map straight to animation progress. The default ease makes the effect feel like it lags and overshoots.
  • Duration is irrelevant for scroll-linked animations: progress comes from the timeline. Some browsers still want a non-zero value; auto is the modern default.
  • Range. By default the whole timeline is used. Use animation-range to run the animation over only part of it.
  • Use both fill. Before and after the active range, animation-fill-mode: both keeps the first or last keyframe in place.
  • Prefer compositor-friendly properties such as transform and opacity so scrolling stays smooth.
  • Accessibility. Parallax and large movement tied to scrolling can cause discomfort. Gate them with @media (prefers-reduced-motion: no-preference).
  • Feature detection. Wrap the declarations in @supports (animation-timeline: scroll()) and make sure content stays visible when the property is unsupported. Never start content at opacity: 0 outside the supports block.

Browser support

Scroll-driven animations are a newer feature and support is not uniform across browsers. Chromium-based browsers have supported them for some time, others have followed or are behind flags, so check a compatibility table and use @supports as a progressive enhancement.