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.

Sponzorirano
Sponzorirano
Sponzorirano
Sponzorirano
Sponzorirano
Traži
Sponzorirano
Virtuala FansOnly
CDN FREE
Cloud Convert
Kategorije
Opširnije
Ostalo
Trends Revolutionizing the Spare Parts Logistics Market
Market Overview According To The Research Report, The Global Spare Parts Logistics Market Was...
Od MAYUR YADAV 2025-10-15 10:50:02 0 115
Art
Test de Ray-Ban Meta: e se seus óculos soubessem mais que você?
óculos Ray-Ban, Ray-Ban Meta, tecnologia de óculos, inovação, realidade aumentada, estilo de...
Od Cecília Heloísa 2025-08-11 04:05:29 1 281
Art
लॉर्ड के क्लियर सीडी में इतने सारे प्लेबैक समस्याएँ क्यों हैं?
## परिचय क्या आपने कभी सोचा है कि सीडी और विनाइल जैसे भौतिक मीडिया का युग खत्म हो गया है? लेकिन...
Od Seema Vandana 2025-08-15 12:05:18 1 241
Art
روبوت المحادثة Grok يثير الجدل ويصف اغتيال تشارلي كيرك بالمزحة!
روبوتات المحادثة, تشارلي كيرك, Grok, الذكاء الاصطناعي, الجدل, السخرية ## مقدمة في عالم يتزايد...
Od Katharina Laura 2025-09-11 23:05:23 1 388
Ostalo
Emerging Trends in the Pizza Boxes Market
Market Overview According To The Research Report, The Global Pizza Boxes Market Was Valued At Usd...
Od MAYUR YADAV 2025-10-15 10:58:17 0 249
Sponzorirano
Virtuala FansOnly https://virtuala.site