Scroll-Driven Animations Inside a CSS Carousel

0
249

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.

Προωθημένο
Προωθημένο
Προωθημένο
Αναζήτηση
Virtualbook
CDN FREE
Κατηγορίες
Διαβάζω περισσότερα
Health
Therapy lasers - SIFSOF
Therapy lasers from SIFSOF are a drug-free, non-invasive pain relief treatment that use the most...
από Shabirkhan 7sk 2025-07-31 05:32:55 0 57
άλλο
High Profile Call Girls in Gurgaon | Independent Escort Services
Call Girls in Gurgaon – High Profile Independent Escorts Are you looking for beautiful and...
από Patola Girls 2025-08-30 19:12:49 0 37
Art
发现数字艺术家的作品,融合个人影响与迷人的乌托邦幻想
数字艺术, 角色插图, 个人影响, 乌托邦幻想, 杰西卡·刘 ## 引言...
από Nan Di 2025-08-15 23:05:29 1 47
Food
Cake Mix Market Report: Size and Share Analysis for 2032
Cake Mix Market Overview: Cake mixes are gaining significant demand from the consumer end due to...
από Cassie Tyler 2024-10-24 04:54:08 0 427
Art
# 梅拉尼亚·特朗普的AI时代来临
梅拉尼亚·特朗普, AI, 首席执行官, 儿童, 科技领导力, 未来, 正面影响, 社会责任, 公众影响力, 教育...
από Juan Han 2025-09-12 07:05:26 1 47
Προωθημένο
Virtuala FansOnly https://virtuala.site