Scroll-Driven Animations Inside a CSS Carousel

0
250

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
Suche
Virtualbook
CDN FREE
Kategorien
Mehr lesen
Food
Glucose Syrup Market Trends 2032 | Revenue, Demand & Competitive Landscape
Glucose Syrup Market Overview: During the projection period of 2022 to 2030, the global market...
Von Cassie Tyler 2025-06-05 13:11:14 0 432
Literature
5 Tips for Maintaining a Life-Size Love Doll
Owning a life-size sex doll is one thing, but taking care of it is another. It is very important...
Von Binged Hugh 2025-04-08 01:48:23 0 432
Art
41 En İyi İşçi Bayramı İndirimleri: WIRED Onaylı Eşyalar (2025)
## Giriş İşçi Bayramı, sadece bir tatil değil; aynı zamanda alışveriş fırsatlarıyla dolu bir...
Von Ömer Berk 2025-08-30 19:05:24 1 48
Art
Marvel gibt NetEase die Erlaubnis zur Schaffung eigener Charaktere für Marvel Rivals
Marvel, NetEase, Marvel Rivals, Charakterentwicklung, Videospiele, Gaming-News, Overwatch 2,...
Von Dina Ronja 2025-08-19 07:05:15 1 30
Art
**Apriamo il taccuino dell'artista di Guerrilla Games Choro Choi**
## Un Viaggio nel Mondo dell'Arte di Choro Choi Nel mondo spietato dei videogiochi, dove la...
Von Daniele Matteo 2025-09-11 04:05:24 1 63
Gesponsert
Virtuala FansOnly https://virtuala.site