Guide to Scroll‑Driven Animations with CSS
June 26, 2025Guide to Scroll‑Driven Animations with CSS
CSS animations can now be linked to user scrolling without any JavaScript — just pure CSS.
1. Three Parts of a Scroll‑Driven Animation
- Target: the element you animate.
- Keyframes: defines the animation steps.
- Timeline: controls animation based on scroll/view, not time.
2. Using scroll() Timeline
Instead of time, the animation progress depends on the user scroll. Example:
footer::after {
content: "";
position: fixed;
bottom: 0;
left: 0;
height: 1em;
width: 100%;
background: gold;
animation: progress-expand;
animation-timeline: scroll();
}
@keyframes progress-expand {
from { width: 0%; }
to { width: 100%; }
}
3. Accessibility Tip
Wrap animations with reduced‑motion preference check:
@media not (prefers-reduced-motion) {
footer::after {
animation: progress-expand;
animation-timeline: scroll();
}
}
4. Advanced: Custom Scroll/View Timelines
Use scroll(nearest block), named timelines, view(), animation-range, and timeline-scope to fine-tune behavior.
Scroll-driven animations now work natively in Safari 26 beta and Chrome 115+, offering smooth, hardware-accelerated UX.
Blog
Jul 06, 2025
Using Web Components the Smart Way A lot of developers assume Web Components are meant to replace full SPA frameworks like React or Vue. But in rea...
Sep 13, 2025
If you want to send Push Notifications from your Laravel app to mobile or web clients, the fastest and simplest way is to use Notifire. It integrate...
Aug 17, 2025
Laravel Global Scopes: Automatic Query Filtering Eloquent Importance: Enforce consistent filters across all model queries (e.g., Soft Del...
Jun 29, 2025
How OAuth Works OAuth is a protocol that allows third-party applications to access user data without sharing passwords. It's the backbone of secure a...
Jun 26, 2025
Guide to Scroll‑Driven Animations with CSS CSS animations can now be linked to user scrolling without any JavaScript — just pure CSS. 1. Thr...
Jul 26, 2025
1. Origins: Born Inside Facebook In 2011, Facebook engineers faced the increasing complexity of building interactive UIs at scale. They developed...