Scroll-Driven Animations Inside a CSS Carousel

0
252

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.

Sponsored
Sponsored
Sponsored
Search
Virtualbook
CDN FREE
Categories
Read More
Art
I tested the WeCreat Vision Pro e fiquei impressionado com o que ele é capaz de fazer
laser cutter, WeCreat Vision Pro, gravador a laser, maker, impressora a laser, tecnologia para...
By Gustavo Diogo 2025-08-03 09:05:30 1 65
Art
US-Regierung fordert medizinische Aufzeichnungen von Trans-Jugendlichen
## Ein Skandal, der uns alle betrifft Es ist an der Zeit, dass wir über die verheerenden...
By Ella Nika 2025-08-23 18:05:22 1 33
Coding
Emulating SQL FILTER with Oracle JSON Aggregate Functions
How to implement FILTER semantics with Oracle JSON aggregate functions A cool standard...
By Luka Matijević 2025-05-31 20:25:33 0 267
Art
كيف تضبط إعدادات الأمان في حاسوبك للحماية من الفيروسات والاختراق؟
## مقدمة: دعونا نحدثكم عن الأمان! في عالم مليء بالفيروسات والاختراقات، يبدو أن أمان الحاسوب هو...
By Katharina Leonie 2025-09-06 07:13:23 1 39
Other
What Are the Key Trends Shaping the Growth of the Kids' Mouthwash Industry?
Mouthwash For Kids Market Overview: The mouthwash for kids market is poised for significant...
By Cassie Tyler 2025-02-27 05:59:54 0 304
Sponsored
Virtuala FansOnly https://virtuala.site