Knowledge baseExam Center
ENEnglish
Choose language13

CKTIS / CSS

timeline-scope — named timeline scope

The timeline-scope property establishes a local scope for scroll and view timeline names, isolating them from names outside a component.

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

Syntax

timeline-scope: none | all | <dashed-ident>#;

timeline-scope does not define a scroll or view timeline source. scroll-timeline or view-timeline defines the named timeline, and animation-timeline selects it by name. If a scoped name has no matching source, it resolves to an inactive timeline. The initial value is none; the property is not inherited or animatable.

none leaves scope unchanged. A comma-separated list of names starting with -- confines those names to the subtree; all covers all names. A nested scope for the same name remains independent.

In the current draft, names are global by default. Scoped lookup selects the last matching timeline in flat-tree order. Older implementations may behave differently.

In the example, the scroller .scroller and .track are siblings under .demo, and the bar .bar is nested inside .track. The shared .demo scope lets .bar look up the --progress timeline defined on .scroller in a different DOM branch. The animation-timeline declaration follows the animation shorthand, which resets it.

Examples

<!doctype html>
<meta charset="utf-8">
<title>timeline-scope</title>
<style>
  .demo { timeline-scope: --progress; }
  .track { width: 200px; background: #ddd; }
  .bar {
    height: 12px;
    background: #1769aa;
    transform-origin: left;
    animation: fill linear both;
    animation-timeline: --progress;
  }
  .scroller {
    width: 200px;
    height: 100px;
    overflow-y: scroll;
    scroll-timeline: --progress y;
  }
  .content {
    height: 500px;
    background: linear-gradient(white, #1769aa);
  }
  @keyframes fill {
    from { transform: scaleX(0); }
    to { transform: scaleX(1); }
  }
</style>
<section class="demo">
  <div class="track"><div class="bar"></div></div>
  <div class="scroller" tabindex="0" aria-label="Scroll area">
    <div class="content"></div>
  </div>
</section>

Result

Expected visual result: the bar is 0px wide at the top, 100px wide at scrollTop = 200, and 200px wide at scrollTop = 400. No console output.

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