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.

Sponsorluk
Sponsorluk
Sponsorluk
Sponsorluk
Sponsorluk
Site içinde arama yapın
Sponsorluk
Virtuala FansOnly
CDN FREE
Cloud Convert
Kategoriler
Read More
Other
How to Build a Portfolio for Media and Communication Careers While in College
In a field as dynamic and competitive as media and communication, having a strong portfolio is...
By Sms Varanasi 2025-06-14 07:53:04 0 620
Food
Coffee Market by Top Competitor, Regional Shares, and Forecast 2032
Coffee Market Overview: Coffee Market Size Anticipated USD 495.07 Billion By 2032, With CAGR Of...
By Cassie Tyler 2024-12-12 06:08:20 0 518
Health
How To Get a Medical Marijuana Card In Pennsylvania
Learn how to get a medical marijuana card in Pennsylvania step by step Find out eligibility...
By Shabirkhan 7sk 2025-07-03 07:26:46 0 213
Other
Deep Space SmallSat Buses Market: Powering the Next Era of Interplanetary Exploration
The Deep Space SmallSat Buses Market is emerging as a transformative segment within the global...
By Riya Sharma 2025-11-02 01:04:01 0 120
Oyunlar
My99Exch: Your Gateway to Smart Online Betting
Online betting has gained massive popularity across India, offering thrill-seekers and sports...
By My99exch My99exch 2025-06-23 15:43:15 0 624
Sponsorluk
Virtuala FansOnly https://virtuala.site