CSS & layout

timeline-scope lets one carousel drive another, no scroll listener required

timeline-scope lets one carousel drive another, no scroll listener required

You know the synced-carousel pattern. Scroll the main strip of products and a second strip somewhere else on the page rolls along with it. You also know how it usually gets built: a scroll listener, a ratio worked out by hand, and a resize handler bolted on after the first bug report. That's a lot of moving parts to make two lists agree on one number.

In a CSS-Tricks article published November 30, Preethi builds it in vanilla CSS. The property doing the heavy lifting is timeline-scope. Here's how the pieces fit together, and why it belongs on the decorative shelf for now.

The scoping rule you keep running into

Named animation timelines have a visibility rule. As the article puts it, an animation timeline can only serve the element that defines it and that element's descendants. Name a scroll timeline on carousel A and A's children can animate against it. Carousel B, sitting next to A as a sibling, can't see the name at all.

That's the wall. In a normal layout two carousels are siblings, not parent and child. (Nobody nests a product strip inside another product strip. Please don't start.)

timeline-scope moves the wall up a level. Put it on an ancestor the two elements share, give it the timeline's name, and every element under that ancestor can use the timeline. One scroll, many elements.

Wiring two strips to one scroll position

The demo markup has a secondary carousel (.cs, with .cs-slide items) and a primary one (.cp, with .cp-slide items). They sit in reverse order in the markup because of how they're positioned on screen. The primary scrolls horizontally with snapping. The secondary gets overflow: clip, so it can't scroll at all and only moves when the animation moves it.

The keyframes push the secondary slides to the left:

@keyframes cs-scroll {
  to {
    transform: translateX(calc(-100% * (sibling-count() - 1)));
  }
}

Then you link everything up:

.carousels {
  timeline-scope: --carousel-scroll;
}

.cp {
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  scroll-timeline: --carousel-scroll x;
}

.cp-slide {
  scroll-snap-align: center;
}

.cs {
  overflow: clip;
}

.cs-slide {
  animation: cs-scroll linear forwards;
  animation-timeline: --carousel-scroll;
}

Read it top to bottom. scroll-timeline on .cp creates a timeline called --carousel-scroll that follows its scroll on the x axis. animation-timeline on each .cs-slide asks for that name. timeline-scope on the shared parent is what lets the lookup succeed. In the main demo that parent is body, because both carousels are its direct children. The article shows the same setup on a wrapper like .carousels if your markup has one.

Notice there's no duration anywhere. You don't need one, and you don't need a delay either, because the animation's progress comes from the scroll position and not from the clock.

Also, that sibling-count() in the keyframes is doing sneaky work. It counts the direct children of the slide's parent, so the translate distance follows however many slides you have. No hardcoded -200% that breaks the day someone adds a fourth slide. Without it, the article says your fallback is indexing items with custom properties right in the markup, which Preethi calls "definitely more cumbersome."

One timeline can feed several animations

The scope is not a one-to-one pipe. According to the article you can do this for as many children as you want, and they don't all have to run the same animation. A stats panel and a thumbnail strip can both follow the same carousel's scroll position, each with its own keyframes.

Preethi's reference points are the car select screen in a racing game, where each car's specs roll past as you browse, and the rotating player profiles on a TV match broadcast. I've lost whole evenings in racing-game garages, flipping through cars I couldn't afford. Seeing that screen come out of a few CSS declarations instead of a scroll handler makes me happier than it probably should.

The support fine print

The article raises two caveats, and you should take both seriously:

  • timeline-scope is not yet Baseline. Preethi recommends it for decorative parts of a page, not for important functionality.
  • sibling-count() is described as nearing Baseline but still rolling out, and not prime time for production.

So treat the synced strip as an enhancement. If the secondary carousel holds something a person actually needs, like the price or the spec that decides the purchase, make sure they can get to it without this animation.

Where I land

The scroll-listener version had a good run. For decorative syncing, this is the tighter build: one named timeline, one scope on the shared parent, and zero JavaScript. Eight out of ten. I'm holding back the last two points until timeline-scope reaches Baseline.

Source: CSS-Tricks (css-tricks.com)

Related
CSS & layout

Overlap detection lands in CSS with anchors and a shared timeline

Ahmad Shadeed shows how to notice when a decoration collides with a section using only CSS: anchor positioning measures the gap, a scroll-driven timeline carries the reaction, and timeline-scope shares it between siblings.

September 25, 2026
CSS & layout

Staggering scroll-driven animations takes one animation-range-start line

On CSS-Tricks, Lee Meyer replaces a formula-heavy stagger technique with a single animation-range-start declaration built on sibling-index(). The reason is that animation-delay has no effect on scroll-driven animations.

November 17, 2026
CSS & layout

Opposing scroll columns with one view() timeline and three keyframe sets

CSS-Tricks walks through making adjacent columns drift in opposite directions as the page scrolls, with no JavaScript. The trick is a per-item animation-timeline: view() and animation-range: entry 0% cover 100%, repeated across three keyframe sets.

June 25, 2026