Scroll-Driven Animations Inside a CSS Carousel

0
464

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
Категории
Больше
Другое
Protein Ice Cream Market, Size, Share, Growth and forecast (2024-2032)
According to the UnivDatos, rising health & wellness trends, and continuous innovation in...
От Praveen Gupta 2025-11-21 07:25:40 0 87
Health
Dialysis Explained: Types, Procedure, and What Patients Should Expect
Kidneys play a vital role in filtering waste, balancing electrolytes, and regulating blood...
От Drtanmay Pandya 2025-10-08 07:24:13 0 180
Другое
經緯航太科技股價|未上市股票即時行情與安全交易平台 - IPO贏家
經緯航太科技未上市股票即時報價查詢!最新行情更新、安全交割保障、完整公司資料與投資討論區。專業平台嚴格把關,降低未上市股票交易風險,點擊查看詳情! 經緯航太股價 與 台灣集保股價 全面解析...
От Shabirkhan 7sk 2025-10-03 05:27:37 0 109
Art
تقنيات العرض: شاشات OLED، تقنية واحدة تحكمهم جميعًا
## مقدمة في عالم اليوم، حيث تتنافس تقنيات العرض المختلفة على انتباه المستهلكين، تبرز شاشات OLED...
От Melina Lina 2025-09-08 00:05:16 1 324
Crafts
Orioles Claim Walter Pennington Orioles Claim Walter Pennington
The Orioles have claimed left-hander off unconditional release waivers, reports . The Rangers had...
От Verna Skiles 2025-10-27 03:46:35 0 73
Спонсоры
Virtuala FansOnly https://virtuala.site