Horizontal Scroll Track
You scroll down, the cards leave to the left: a track of five 180 px cards, pinned in the middle of a 280 px frame, slides 364 px during 520 px of scrolling and stops when the last card meets the right edge. The CSS works out the distance by itself; a 1 KB script replays the slide in Firefox.
Updated
This effect is part of Effect.Labs — 846 vanilla effects, some free, some premium. Scroll has 74 effects, including 12 free. Explore the category →
3 usage examples



How it works
Three nested boxes under .fx-0564-root. The .sdc-scroll-container area (280 px tall, 640 px wide at most) scrolls vertically. The .sdc-horiz-content tray, 800 px tall, is only there to give 520 px of travel; it trims what sticks out with overflow: clip, which does not create a scroll container. The .sdc-horiz-track track is position: sticky; top: 50% with a translateY(-50%): it stays centred in the frame (top at 70 px) while the tray goes by.
The slide is one keyframe, fx0564Glisse, wired to animation-timeline: scroll(). Its end state reads translateX(min(0px, calc(100cqw - 100%))): 100% is the track's width (it is width: max-content, 1,004 px for five cards), 100cqw the tray's, declared container-type: inline-size. The difference is exactly what overflows. Measured: −84 px at 120 px of scrolling, −182 px midway, −364 px at the end in a 640 px frame; −614 px in a 390 px frame. With eight cards and no CSS change: −952 px, last card 20 px from the right edge.
The motion is linear and reversible: scrolling back up brings the cards back. If the track already fits the frame (two cards, 416 px), min() keeps 0 and nothing moves. For browsers without animation-timeline, the script that ships with it puts the same keyframe on the track in a paused state and sets its currentTime on every scroll event; it looks up its elements root by root, so two copies stay independent (the second at 520 px, the first at 0). In Firefox 151 it yields the same positions as the CSS does in Chromium, to the pixel.
Accessibility
- Reduced motion: content that leaves sideways while you scroll down is precisely what
prefers-reduced-motionasks you to avoid. In that mode the code drives nothing: the track lies flat (position: static, no animation), the area switches to native horizontal scrolling with 364 px to cover, the “Scroll ↓” hint is hidden and the fallback script stops at its second test. Flat track and 364 px of horizontal scrolling read in all three engines. - Keyboard: the area takes focus (
tabindex="0",role="region",aria-label) with a 2 px violet outline. The up and down arrows slide the track: four presses, 160 px of scrolling in Chromium, 204 px in Firefox. The cards are not links. Mind what happens if you make them links: tried in all three engines, Tab also reaches the fourth and the fifth, but the area does not scroll to show them — focus lands on a card outside the frame. You will then have to scroll the area yourself onfocusin. - Reading: the five cards are in the HTML in track order. A screen reader reads them all, including those still outside the frame on the right. The pictograms are decorative (
aria-hidden). The second line of each card sits at 7.1:1 on the card background. - Touch: the finger scrolls the area vertically, like the wheel — a 150 px drag, 149 px of scrolling in Chromium emulation. Swiping sideways does nothing, except in reduced motion where the track is indeed browsed sideways. That is counter-intuitive for a row of cards: keep a visible hint.
Browser compatibility
The native slide needs animation-timeline: scroll(): Chrome and Edge 115, Safari 26, Firefox 159 per MDN. cqw units and overflow: clip are older (Chrome 105, Safari 16, Firefox 110). Measured: Chromium 149 and WebKit 26.5 through the CSS (WebKit stops at −368 px, its scrollbar eats 4 px of frame); Firefox 151 through the fallback script, same values as Chromium.
The fallback script tests CSS.supports('animation-timeline', 'scroll()') and does nothing when the answer is yes. Otherwise it replays the CSS keyframe: the distance is still worked out by min() and cqw, nothing is duplicated in JavaScript. Without the script, a browser lacking animation-timeline shows a motionless track, the first cards visible and the others cut off.
The code
HTML structure to paste into your page (the CSS + JS come with your purchase):
<div class="fx-0564-root">
<div class="sdc-scroll-container" tabindex="0" role="region" aria-label="…">
<div class="sdc-horiz-content">
<div class="sdc-horiz-track">
<div class="sdc-horiz-card">
<div class="sdc-horiz-card-icon" style="background:…">
<svg viewBox="0 0 24 24" aria-hidden="true" focusable="false">…</svg>
</div>
<h4>…</h4>
<p>…</p>
</div>
… ×5
</div>
</div>
</div>
<span class="sdc-scroll-hint" aria-hidden="true">…</span>
</div>
One-time payment, no subscription — the code is yours forever
Customize
Options passed to the API or data-* attributes:
| Option / property | Default | Effect |
|---|---|---|
Number of cards (HTML — .sdc-horiz-card) |
5 cards, a 1,004 px track | Add or remove cards without recomputing anything: eight cards slide 952 px and stop at the same spot, 20 px from the right edge. Below the frame's width the track stays still. |
Frame width (CSS — .sdc-scroll-container { max-width: 640px }) |
640 px at most, centred | Widen it only if the track still overflows. Tried with no cap on a 1,280 px screen: the five cards fit the frame, the slide is 0 and you scroll 520 px for nothing. |
Travel (CSS — .sdc-horiz-content { height: 800px }) |
800 px, i.e. 520 px of scrolling for 364 px of slide | The ratio of the two sets the apparent speed. Tray height = frame height + overflowing width: the track then moves one pixel per scrolled pixel. height: auto if the tray holds content. |
Card height (CSS — .sdc-horiz-card { height: 140px }) |
140 px, half the frame | Beyond half the frame, the pinned track no longer fits the tray at the end of the travel and moves up. Make up for it with a negative margin-bottom on the track: card height minus half the frame (−60 px for 200 px). |
Pinning notch (CSS — .sdc-horiz-track { top: 50% }) |
middle of the frame | The keyframe keeps the translateY(-50%). To stick the track to the top, give top half the track's height (27 px for 54 px) rather than 0. |
| Fallback script (JS — 1 KB) | included, active only without animation-timeline |
Remove it if a motionless track is fine for you in Firefox before 159. If you rename the fx0564Glisse keyframe, rename it in the el.style.animation line as well. |
Hint (HTML — span.sdc-scroll-hint) |
“Scroll ↓” | Here the hint earns its place: nothing about a row of cards says you should scroll down. Keep it or swap it for a marker of your own. |
FAQ
scroll-timeline: --hscrollTimeline), pins a solid block as tall as the frame and translates the track by −75% of its width; in Firefox its fallback CSS lays the track flat. Here the timeline is anonymous (scroll(), the nearest scrolling ancestor), the track is a row of cards centred in the frame, the distance is computed to end on the last card, and Firefox gets the same slide through a script. Pick this one for a row of cards whose number changes; the other for large panels without a line of JavaScript.min(0px, …) returns 0 — measured with two cards (416 px in 640). Then the scrolling ancestor: scroll() takes the first one it finds, so a box with overflow: auto or hidden slipped between the area and the track becomes the timeline, and it does not scroll. That is why the tray uses overflow: clip.sticky element cannot leave its parent. With top: 50% the track's box starts at the middle of the frame: if it is more than half a frame tall, it runs into the bottom of the tray at the end of the travel. Measured with 200 px cards: the track climbs 60 px over the last 60 pixels. margin-bottom: -60px on the track (card height minus half the frame) fixes it, checked: it stays 40 px from the top all the way.