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.

Προωθημένο
Προωθημένο
Προωθημένο
Προωθημένο
Προωθημένο
Αναζήτηση
Προωθημένο
Virtuala FansOnly
CDN FREE
Cloud Convert
Κατηγορίες
Διαβάζω περισσότερα
άλλο
What to Look for in a 24/7 Emergency Service Provider
A burst pipe is a rude, inconsiderate thing. It doesn't care that it's 2:00 AM on a holiday. It...
από Sharpline Inc 2025-11-20 11:27:04 0 72
Art
PlayStation lancia un'app familiare per il controllo parentale e filtri dei contenuti
controllo parentale, PlayStation, app familiare, limiti di spesa, monitoraggio del tempo di...
από Alessia Erica 2025-09-12 11:05:21 1 735
Art
Où trouver le minerai de fer dans Monster Hunter Wilds ?
## Einleitung In der schillernden und doch gnadenlosen Welt von Monster Hunter Wilds ist der...
από Clara Ida 2025-08-23 09:05:25 1 383
άλλο
Single-Use Assemblies Market Strategic Collaborations and Supply Agreements 2022–2030
Market Synopsis:The market for single-use assembly is expanding significantly because the...
από Manisha Kashid 2025-05-09 09:03:22 0 319
Art
High on Life 2: Ein aufregendes Abenteuer, das wir auf der Gamescom erlebt haben
High on Life 2, Gamescom, Gaming, Abenteuer, Videospiele, Entertainment, Entwickler, Spielemesse,...
από Sara Lia 2025-08-31 05:05:24 1 368
Προωθημένο
Virtuala FansOnly https://virtuala.site