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.

Gesponsert
Gesponsert
Gesponsert
Gesponsert
Gesponsert
Suche
Gesponsert
Virtuala FansOnly
CDN FREE
Cloud Convert
Kategorien
Mehr lesen
Spiele
Understanding Black Ops 7 DLC Content and Free Updates with Bo7 Bot Lobby Service
When investing $70 in Black Ops 7, players naturally want to know about the DLC content and the...
Von Claus Oliver 2025-10-20 06:05:45 0 300
Spiele
Best Live Baccarat Tables You Can Play in India Right Now
If you're searching for the best Live Baccarat tables in India, you’ve come to the right...
Von Armani Exch247 2025-07-28 12:02:47 0 390
Spiele
777xp
Stay ahead in the gaming universe with 777xp. Featuring in-depth game guides, tips, and news,...
Von David Walton 2025-10-28 23:08:19 0 151
Art
Entscheidung von Google: Nähern sich Android und iOS an?
Google, Android, iOS, Technologie, Smartphone, Betriebssystem, Mobile, Innovation,...
Von Marie Anna 2025-08-28 00:05:16 1 432
Andere
I just made my first zine, here's what I learned
I just made my first zine, here's what I learned (Image credit: Mabel Wynne) What...
Von Lana Jurčić 2025-07-13 09:09:14 0 146
Gesponsert
Virtuala FansOnly https://virtuala.site