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
Căutare
Sponsor
Virtuala FansOnly
CDN FREE
Cloud Convert
Categorii
Citeste mai mult
Home
Asbesthaltiger Boden & Bodenkleber & Floorflexplatten Neunkirchen-Seelscheid
Von Floorflex, Cushion-Vinyl, asbesthaltigem Vinylboden bis zum Abschliff von asbesthaltigen...
By Shabirkhan 7sk 2025-11-13 10:17:44 0 67
Alte
Linear Alkyl Benzene Market, Size, Share, Growth, Trends and Forecast (2025-2033)
According to UnivDatos, the rising global demand for biodegradable products, coupled with the...
By Praveen Gupta 2025-11-04 06:41:22 0 85
Jocuri
How to Unlock Traveler’s Fruit in Grow A Garden
If you’re diving into Grow A Garden and aiming to unlock the elusive Traveler’s...
By WillowBloom WillowBloom 2025-10-24 08:39:26 0 209
Gardening
Entrümpelung & Haushaltsauflösung Siegburg 02241-2664987
Entrümpelung Siegburg und Entrümpelung Waldbröl – Effizient, Sauber,...
By Sharif Khan 2025-08-07 06:03:11 0 327
Art
ساعة سامسونج الذكية "جالاكسي رينغ" تصل إلى أدنى سعر لها على الإطلاق بـ 299.99 دولار
ساعة ذكية، جالاكسي رينغ، خصم، تكنولوجيا، سامسونج، أجهزة ذكية، أسعار ## مقدمة في عالم...
By رامي جابر 2025-08-18 20:05:21 1 218
Sponsor
Virtuala FansOnly https://virtuala.site