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.

إعلان مُمول
إعلان مُمول
إعلان مُمول
إعلان مُمول
إعلان مُمول
البحث
إعلان مُمول
Virtuala FansOnly
CDN FREE
Cloud Convert
الأقسام
إقرأ المزيد
Crafts
Craig Counsell gets into testy argument with Cubs reporter Bad take
Cubs manager Craig Counsell wasnt thrilled with ESPN reporter Je se Rogers characterization of a...
بواسطة Verna Skiles 2025-10-27 03:41:33 0 84
Sports
Very little Traces 4/17: Roman Anthony goes backyard garden 2 times, WooSox no-strike Rochester
Match 1: Worcester Crimson Sox 8, Rochester Crimson Wings 0 Soon after a postponement because of...
بواسطة Perales Perales 2025-04-29 01:31:54 0 629
Health
Can Physiotherapy Provide Relief for Chronic Pain from Shingles?
Physiotherapy can be an effective approach to alleviating chronic pain associated with shingles,...
بواسطة In Step Physiotherapy Edmonton 2024-10-22 18:11:48 0 674
Art
Picking an Old Operating System: Un Viaggio nel Passato dell'Informatica
sistemi operativi, hardware obsoleto, storia dell'informatica, nostalgia tecnologica, database...
بواسطة Elena Irene 2025-08-23 19:05:26 1 316
أخرى
Immersive Learning on the Rise: What’s Powering the Simulators Market Boom
Defence organisations worldwide are undergoing rapid restructuring to strengthen readiness,...
بواسطة Amol Shinde 2025-11-28 04:40:39 0 22
إعلان مُمول
Virtuala FansOnly https://virtuala.site