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
دسته بندی ها
ادامه مطلب
دیگر
股票下市怎麼辦?下市股票的處理建議
當一家公司的股票下市,並不代表投資人手中的股票會變成無價值的紙張。實際上,這間公司還是存在,只是沒有上市,它們只能在場外交易市場私人間買賣,這可能會導致股票交易量少、流動性較差。...
توسط Shabirkhan 7sk 2025-09-17 06:37:09 0 194
صفحه اصلی
Asbestsanierung in Kempen 0231-98194868
Von A wie Asbesterkennung bis S wie Schadstoffanalyse. Wir helfen fachmännisch nach der TRGS...
توسط Shabirkhan 7sk 2025-05-27 07:55:03 0 257
صفحه اصلی
Drzwi i Okna Jastrzębie Zdrój - Panorama System
Dokładamy wszelkich starań aby nasze realizacje były naszą reklamą. W naszej ofercie znajdziesz...
توسط Shabirkhan 7sk 2025-09-02 04:53:49 0 291
Art
Battlefield 6: Die ruhige Revolution im Chaos der Schlachtfelder
Battlefield, Battlefield 6, Spielanpassungen, Gameplay, EA, Rush-Modus, Shotgun-Nerf, Open-Beta,...
توسط Clara Ida 2025-08-22 04:05:18 1 191
دیگر
Enteric Disease Testing Market Analysis and Opportunities
Market OverviewAccording To The Research Report Published By Polaris Market Research, The Global...
توسط MAYUR YADAV 2025-09-25 10:38:45 0 164
حمایت‌شده
Virtuala FansOnly https://virtuala.site