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.

Sponzorováno
Sponzorováno
Sponzorováno
Sponzorováno
Sponzorováno
Hledat
Sponzorováno
Virtuala FansOnly
CDN FREE
Cloud Convert
Kategorie
Číst více
Sports
Fairdeal Pro Casino Online Slots: A Complete Guide for Indian Players
Online slots are one of the most popular attractions in the digital gaming industry. Easy to...
Od Fairdeal Pro 2025-09-25 11:51:08 0 362
Art
Rediscovering Microsofts seltsamen Musikgenerator aus den 1990er Jahren
## Einführung Es ist an der Zeit, einen Blick zurückzuwerfen auf eine der skurrilsten...
Od Dina Luisa 2025-08-15 07:05:36 1 423
Art
Vergessen Sie den Prime Day, Amazon senkt den Preis des iPad Air 2025 auf ein neues Allzeittief
## Einführung Die Welt der Technik hat wieder einmal ihre Preise gesenkt, und dieses Mal ist es...
Od Nele Nika 2025-08-28 09:05:51 1 414
Domů
Asbesthaltiger Boden & Bodenkleber & Floorflexplatten Much
Von Floorflex, Cushion-Vinyl, asbesthaltigem Vinylboden bis zum Abschliff von asbesthaltigen...
Od Shabirkhan 7sk 2025-09-12 09:26:13 0 103
Food
Canned Tuna Market expected to reach an estimated value of USD 16.07 by 2030
Introduction Canned Tuna Market Size was valued at USD10,258.36 million in 2021. The Canned Tuna...
Od Cassie Tyler 2025-01-30 05:41:46 0 505
Sponzorováno
Virtuala FansOnly https://virtuala.site