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.

Patrocinados
Patrocinados
Patrocinados
Patrocinados
Patrocinados
Buscar
Patrocinados
Virtuala FansOnly
CDN FREE
Cloud Convert
Categorías
Read More
Food
Dietary Supplements Market Trends, Size, Share, and Analysis – Forecast to 2032
Dietary Supplements Market Overview: Dietary supplements are medicines designed to provide a...
By Cassie Tyler 2024-12-06 06:21:26 0 521
Art
Nintendo: Le Nuove Animazioni Stop-Motion di Mario Sono Pura Nostalgia Infantile
Nintendo, animazioni stop-motion, Mario, anniversario, nostalgia, infanzia, cortometraggi,...
By Alessia Erica 2025-08-27 13:05:30 1 452
Other
Home manicure products gaining traction as consumers adopt DIY beauty practices
Polaris Market Research has introduced the latest market research report titled Nail Care...
By MAYUR YADAV 2025-11-25 11:33:13 0 45
Juegos
Learn All Basic Aspects About Buy Poe 2 Currency Now!
Currency in POE 2 refers to various items used for crafting equipment and increasing...
By Dawcear Cear 2025-01-27 05:19:22 0 705
Dance
How Taking an Online Class Can Improve Your Academic Performance
The world of online education has evolved significantly in recent years, providing students with...
By Imli Lokt 2025-01-30 13:16:31 0 661
Patrocinados
Virtuala FansOnly https://virtuala.site