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.

حمایت‌شده
حمایت‌شده
حمایت‌شده
جستجو
Virtualbook
CDN FREE
دسته بندی ها
ادامه مطلب
Art
### Instagram si lancia nel mondo delle mappe sociali per competere con Snapchat
Instagram, il social network che ha conquistato il cuore di milioni di utenti in tutto il mondo,...
توسط Stefano Sergio 2025-08-10 20:05:24 1 43
Art
Test Wheel World: O Mundo Aberto que Valoriza a Bicicleta
mundo aberto, Test Wheel World, Messhof, jogos de bicicleta, ActuGaming.net, videogames,...
توسط Liz Mónica 2025-08-17 15:05:21 1 69
Art
MCM Bourse pour les créatifs aspirants : un retour pour financer la prochaine génération de talents
bourse MCM, créatifs, développeurs de jeux, artistes, designers, talents émergents, carrière...
توسط Sacha Rémi 2025-09-05 22:05:19 1 40
دیگر
Smart Cities and Their Impact on Location Analytics Industry
The newly published study by Polaris Market Research, titled Location Analytics Market, delves...
توسط MAYUR YADAV 2025-09-01 13:52:17 0 21
Life
Uskoro stupa na snagu velika promjena za vlasnike kućnih ljubimaca
Uskoro stupa na snagu velika promjena za vlasnike kućnih ljubimacaDora Perši iz Udruge Indigo...
توسط Lana Jurčić 2025-07-21 12:40:51 0 103
حمایت‌شده
Virtuala FansOnly https://virtuala.site