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.

Commandité
Commandité
Commandité
Commandité
Commandité
Rechercher
Commandité
Virtuala FansOnly
CDN FREE
Cloud Convert
Catégories
Lire la suite
Art
8 Tendências Icônicas de Moda dos Últimos 50 Anos: Uma Reflexão sobre a Mudança
tendências de moda, moda icônica, silhuetas de gênero neutro, moda dos anos 70, moda dos anos 80,...
Par Fernando Manuel 2025-08-02 14:49:14 1 238
Art
Resident Evil Requiem: Il Trailer Angosciante che Fa Tremare!
Resident Evil, trailer, Grace, madre, horror, video giochi, ActuGaming.net, suspense, gioco...
Par Teresa Nicole 2025-08-19 21:05:24 1 355
Life
A Love Written in the Stars
**A Love Written in the Stars: Emma and Lucas’s Story** In a world that often feels rushed...
Par Gwen Heathcote 2025-01-28 22:21:30 0 519
Health
Finding the Best Gastroenterologist in Ranchi: An Informational Guide
  Digestive health is a vital part of overall well-being, yet it is often overlooked...
Par Dr Chandan Kumar Yadav 2025-09-09 11:24:53 0 268
Commandité
Virtuala FansOnly https://virtuala.site