Knowledge baseExam Center
ENEnglish
Choose language13

CKTIS / CSS

scroll-timeline — a named scroll progress timeline

The scroll-timeline shorthand defines a named timeline on a scroll container. An animation using that timeline advances with scroll position rather than elapsed time.

Version: CSS modules; structured CSSWG indexes reconciled with pinned MDN BCD; Chromium 152 scope gate, per-example verification still required

Syntax

scroll-timeline: [ <'scroll-timeline-name'> <'scroll-timeline-axis'>? ]#;

scroll-timeline combines scroll-timeline-name and scroll-timeline-axis. Names start with --; none defines no named timeline. An omitted axis becomes block. Commas separate multiple definitions. The property is neither inherited nor animatable.

block and inline depend on writing mode; x and y denote physical axes. Without a scroll range on the selected axis, the timeline is inactive. Progress follows position across the entire scroll range, not an element's visibility.

The declaration alone does not start an animation. In the example, a descendant selects --progress through animation-timeline. Place that declaration after animation, because the shorthand resets the timeline selection. Scrolling backward reverses the effect. This exact version of the example passed a structural check in an isolated browser. That check does not establish that the bar width was measured at every listed scroll position. Check behavior in the target browser before deployment.

Examples

<!doctype html>
<meta charset="utf-8">
<title>scroll-timeline</title>
<style>
  .scroller {
    width: 240px;
    height: 160px;
    overflow: auto;
    scroll-timeline: --progress block;
  }
  .content { height: 640px; }
  .bar {
    position: sticky;
    top: 0;
    height: 12px;
    background: teal;
    transform-origin: left;
    animation: fill linear both;
    animation-timeline: --progress;
  }
  @keyframes fill {
    from { transform: scaleX(0); }
    to { transform: scaleX(1); }
  }
</style>
<div class="scroller" tabindex="0" aria-label="Scroll demo">
  <div class="content"><div class="bar"></div></div>
</div>

Result

Expected visual result: the teal bar has zero width at scrollTop 0, half width at scrollTop 240, and full width at scrollTop 480. Scrolling backward reverses the change.

The displayed code and declared result were verified in an isolated environment using the method recorded in the verification evidence for this exact version.

Sources