Scroll-Driven Animations Inside a CSS Carousel

0
462

Scroll-Driven Animations Inside a CSS Carousel | CSS-Tricks

I was reflecting on what I learned about CSS Carousels recently. There’s a lot they can do right out of the box (and some things they don’t) once you define a scroll container and hide the overflow.

Hey, isn’t there another fairly new CSS feature that works with scroll regions? Oh yes, that’s Scroll-Driven Animations. Shouldn’t that mean we can trigger an animation while scrolling through the items in a CSS carousel?

Why yes, that’s exactly what it means. At least in Chrome at the time I’m playing with this:

It’s as straightforward as you might expect: define your keyframes and apply them on the carousel items:

@keyframes foo {
  from {
    height: 0;
  }
  to {
    height: 100%;
    font-size: calc(2vw + 1em);
  }
}

.carousel li {
  animation: foo linear both;
  animation-timeline: scroll(inline);
}

There are more clever ways to animate these things of course. But what’s interesting to me is that this demo now combines CSS Carousels with Scroll-Driven Animations. The only rub is that the demo also slaps CSS Scroll Snapping in there with smooth scrolling, which is effectively wiped out when applying the scroll animation.

I thought I might work around that with a view() timeline instead. That certainly makes for a smoother animation that is applied to each carousel item as they scroll into view, but no dice on smooth scrolling.

Sponsor
Sponsor
Sponsor
Sponsor
Sponsor
Zoeken
Sponsor
Virtuala FansOnly
CDN FREE
Cloud Convert
Categorieën
Read More
Art
Genshin Impact: Unterstützung für PS4 endet bald – Ein Abschied voller Erinnerungen
Genshin Impact, PS4, Gaming, PlayStation, Spielerfahrung, Community, RPG, Abenteuer, Zukunft des...
By Lena Nele 2025-08-06 20:05:31 1 212
Spellen
Rooster Pet — Grow A Garden Rare Pet Info
If you’ve been tending your virtual garden in Grow A Garden, you might have noticed that...
By Gumball Gumball 2025-11-22 09:45:29 0 105
Art
Tutorials: Rendering Matte Surfaces – Volumes 1 und 2
## Einführung Es ist an der Zeit, die rosarote Brille abzunehmen und sich der brutalen Realität...
By Ronja Maja 2025-09-14 05:05:21 1 712
Art
e-Waste und Altöl: Gemeinsam Silber herstellen
E-Waste, Altöl, Recycling, Umweltbewusstsein, Kreislaufwirtschaft, nachhaltige Technologie,...
By Ronja Theresa 2025-09-15 02:05:21 1 469
Art
Indie publisher Firestoke chiude nonostante essere sulla "strada verso la redditività"
editoria indie, Firestoke, chiusura, giochi indie, perdita, industria dei videogiochi, profitto,...
By Laura Anna 2025-08-07 08:56:10 1 124
Sponsor
Virtuala FansOnly https://virtuala.site