Scroll-Driven Animations Inside a CSS Carousel

0
464

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.

Patrocinado
Patrocinado
Patrocinado
Patrocinado
Patrocinado
Pesquisar
Patrocinado
Virtuala FansOnly
CDN FREE
Cloud Convert
Categorias
Leia Mais
Art
Como os desenvolvedores podem aproveitar ao máximo as vitrines de streaming
## Introdução Em um mundo repleto de jogos grandiosos e gráficos impressionantes, muitas vezes...
Por Fernando Manuel 2025-08-27 16:05:31 1 352
Art
This Bodycam Footage Rache-Thriller könnte die nächste große Kontroversen im Gaming auslösen
Gaming, Kontroversen, Bodycam Footage, Rache-Thriller, Better Than Dead, hyper-realistischer...
Por Hannah Jana 2025-08-16 06:05:35 1 478
Art
Borderlands Fanart Tutorial: Claptrap Vollcharakter Selbst Erstellen
Borderlands, Fanart, Claptrap, Tutorial, Grease Pencil, digitale Kunst, 3D-Modellierung,...
Por Lara Anna 2025-09-17 04:05:29 1 726
Outro
Future Outlook and Competitive Strategies in the Global Porous Ceramic Market
The global porous ceramic market was valued at USD 7.89 billion in 2023 and is projected to reach...
Por MAYUR YADAV 2025-09-02 11:55:42 0 121
Outro
Creatine Monohydrate: The Ultimate Supplement for Strength and Performance
If you're looking to boost your strength, endurance, and muscle recovery, Creatine Monohydrate is...
Por Seoservicesin India 2025-03-02 04:14:15 0 590
Patrocinado
Virtuala FansOnly https://virtuala.site