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.

Sponsorizzato
Sponsorizzato
Sponsorizzato
Sponsorizzato
Sponsorizzato
Cerca
Sponsorizzato
Virtuala FansOnly
CDN FREE
Cloud Convert
Categorie
Leggi tutto
Art
Marvel gibt NetEase die Erlaubnis zur Schaffung eigener Charaktere für Marvel Rivals
Marvel, NetEase, Marvel Rivals, Charakterentwicklung, Videospiele, Gaming-News, Overwatch 2,...
By Dina Ronja 2025-08-19 07:05:15 1 162
Art
Teardown eines billigeren EBL Multi-Cell NiMH-Ladegeräts
NiMH-Ladegeräte, EBL, Akku-Ladegeräte, Batterien, Elektronik, Tests, Teardown, Gadgets, Technik...
By Marie Isabel 2025-09-07 05:05:23 1 411
Art
HP bringt die neue digitale Druckmaschine Indigo 6K+ auf den Markt: Ein überbewerteter Schritt in die falsche Richtung
HP, ein Unternehmen, das sich selbst als Innovator und Vorreiter in der Drucktechnologie sieht,...
By Dina Luisa 2025-08-12 08:05:26 1 122
Art
Mon premier aperçu de la dernière imprimante 3D H2S de Bambu Lab
## Introduction La magie de l'impression 3D continue d'évoluer, et Bambu Lab nous offre un...
By Romain Thomas 2025-08-26 22:05:28 1 306
Art
كيف تستخدم Google Lens لحل المعادلات؟
حل المعادلات، Google Lens, تقنيات التعلم، أدوات تعليمية، التعلم الذاتي ## مقدمة في عالمٍ مليء...
By Nele Johanna 2025-08-29 12:05:17 1 267
Sponsorizzato
Virtuala FansOnly https://virtuala.site