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.

Patrocinado
Patrocinado
Patrocinado
Patrocinado
Patrocinado
Pesquisar
Patrocinado
Virtuala FansOnly
CDN FREE
Cloud Convert
Categorias
Leia mais
Outro
Key Trends Driving the Elevator Control System Market
Market Overview According To The Research Report, The Global Elevator Control System Market Was...
Por MAYUR YADAV 2025-10-15 11:12:53 0 175
Outro
Innovations Shaping the Nuclear Waste Management System Market
Market Overview According To The Research Report, The Global Nuclear Waste Management System...
Por MAYUR YADAV 2025-10-15 10:50:17 0 118
Outro
Polyethylene Terephthalate Glycol Market, Size, Share, Growth, Trends and Forecast (2025-2033)
The Global Polyethylene Terephthalate Glycol Market, inducing technological innovation, high...
Por Praveen Gupta 2025-10-28 07:21:55 0 176
Art
Conjuring 4: Das Popcorn-Eimer-Feature mit Annabelle und die gemischten Reaktionen der Fans
Conjuring 4, Popcorn-Eimer, Annabelle, Horror-Fans, enttäuschte Erwartungen, Sammlerstücke,...
Por Melina Mathilda 2025-08-19 03:05:18 1 274
Jogos
How to Catch or Buy Pidgeotto in Pokémon Legends: Z-A
In Pokémon Legends: Z-A, one of the classic Flying-type Pokémon you can...
Por Olivia OliviaGriff 2025-10-22 07:42:23 0 531
Patrocinado
Virtuala FansOnly https://virtuala.site