Scroll-driven animations link a normal CSS @keyframes animation to scrolling instead of time. Set animation-timeline: view() to play an animation as an element moves through the viewport, or animation-timeline: scroll() to tie it to how far a page or container has scrolled. As of October 2026 they work in Chrome and Edge 115+ and Safari 26+; Firefox is still working on them, so wrap them in @supports and treat them as an enhancement.
Key takeaways
view()tracks an element crossing the viewport: ideal for fade-in and slide-up reveals.scroll()tracks scroll position: ideal for reading progress bars and parallax.animation-rangecontrols which part of the scroll plays the animation, for exampleentry 0% cover 35%.- Set
animation-timelineafter theanimationshorthand, use@supports, and respectprefers-reduced-motion.
What are scroll-driven animations?
For years, “animate on scroll” meant JavaScript: an IntersectionObserver or a scroll listener that added classes or set styles as you scrolled. Scroll-driven animations move that job into CSS. You write the keyframes as usual, then swap the timeline. Instead of running over a number of seconds, the animation’s progress follows the scroll position, so scrolling back up plays it in reverse, and the browser can run it off the main thread for smoother results.
How do you make an element fade in on scroll?
@keyframes reveal {
from { opacity: 0; translate: 0 40px; }
to { opacity: 1; translate: 0 0; }
}
@media (prefers-reduced-motion: no-preference) {
@supports (animation-timeline: view()) {
.reveal {
animation: reveal linear both;
animation-timeline: view();
animation-range: entry 0% cover 35%;
}
}
}
Add the reveal class to any card, image or heading. Browsers without support, and people who have asked their device for less motion, simply see the content without the effect.
Common mistake: The animation shorthand resets animation-timeline. If you write animation-timeline first and the shorthand after it, the timeline is quietly reset and the animation runs on time instead. Always put the timeline after the shorthand.
How does animation-range work?
animation-range chooses the slice of the element’s journey that drives the animation. Each value is a named range plus a percentage:
| Range | Means | Example use |
|---|---|---|
entry | From the element’s first edge appearing to it being fully inside the viewport | Fade in as it arrives |
exit | From starting to leave to fully gone | Fade out as it leaves |
contain | While it is fully inside the viewport (or fully covering it, if taller) | Effects while it is completely on screen |
cover | From first edge entering to last edge leaving: the whole journey | Parallax, long reveals |
entry-crossing / exit-crossing | The element crossing the start or end edge | Fine control on tall elements |
entry 0% cover 35% starts the moment the top of the element peeks in at the bottom of the screen and finishes when it is a little over a third of the way through. Short ranges feel snappy; long ranges feel more cinematic but can leave content half-faded while people are trying to read it.
How do you make a reading progress bar in CSS?
.progress {
position: fixed;
inset: 0 0 auto 0;
height: 4px;
background: #7b5cff;
transform-origin: 0 50%;
animation: grow linear both;
animation-timeline: scroll(root block);
}
@keyframes grow {
from { transform: scaleX(0); }
to { transform: scaleX(1); }
}
scroll(root block) follows the whole page’s vertical scroll. Use scroll(nearest) to follow the closest scrolling ancestor instead, such as a scrollable panel. Animating transform rather than width keeps it smooth, because transforms don’t trigger layout.
Named timelines
When the element that scrolls isn’t an ancestor of the element you want to animate, give the scroller a name with scroll-timeline-name (or view-timeline-name) and refer to it from elsewhere with animation-timeline: --name. For most reveals and progress bars, the anonymous view() and scroll() functions are enough.
Which browsers support scroll-driven animations?
| Browser | Support (October 2026) |
|---|---|
| Chrome and Edge | 115 and later |
| Safari (macOS and iOS) | 26 and later |
| Firefox | Not yet by default; available behind a flag |
| Samsung Internet and other Chromium browsers | Yes |
Because the @supports wrapper hides the effect where it isn’t available, unsupported browsers show the content normally. Never hide content in a way that depends on the animation running; the starting state should only be applied inside the @supports block, as in the examples above.
Do you still need JavaScript for scroll effects?
For reveals, progress bars and simple parallax, no. CSS now covers them with less code and smoother results. JavaScript is still the right tool when something needs to happen once at a point in the scroll, such as loading more items, sending an analytics event or starting a video, because scroll-driven animations only map scroll position to keyframes. They don’t fire events. If you need the same reveal in Firefox today, a small IntersectionObserver script can add the class as a fallback, but for most sites the plain content is a perfectly good experience.
Accessibility and good taste
- Respect reduced motion. Wrap motion in
prefers-reduced-motion: no-preference, so people with vestibular disorders aren’t made unwell. - Animate opacity and transform. These are cheap for the browser. Avoid animating
height,topor largefilterblurs. - Don’t reveal everything. Animating every paragraph is tiring. Save it for images, cards and section headings.
- Finish early. End reveals well before content reaches the middle of the screen, so it is fully visible by the time someone reads it.
Generate the code
The Refract scroll-driven animation generator gives you fade, slide up, scale, wipe and unblur reveals plus a reading progress bar. You preview each effect by scrolling, set the range, then copy CSS that already includes the @supports fallback and reduced-motion check. Its “Paste into” menu rewrites the code for Elementor, Divi, Bricks, Breakdance or the block editor. For time-based motion, try the CSS loader generator or the button hover effects generator.
Last checked: October 2026.
Sources: MDN: CSS scroll-driven animations, MDN: animation-range, Chrome for Developers: scroll-driven animations.


