Notes on Reverse-Scrolling Columns With CSS Scroll-Timeline

Lemme do this one quick-hits style:


Notes on Reverse-Scrolling Columns With CSS Scroll-Timeline originally published on CSS-Tricks. You should get the newsletter and become a supporter.


This content originally appeared on CSS-Tricks and was authored by Chris Coyier

Lemme do this one quick-hits style:

Showing three columns of photos of actresses demonstrating the CSS scroll-timeline effect. The first and their columns scroll up and down together. The second columns scrolls the opposite direction.

CSS Scroll-Timeline with prefers-reduced-motion

The only thing I’d add is something to honor prefers-reduced-motion, as I could see this sort of scrolling motion affecting someone with motion sickness. To do that, you could combine tests in the same line the support test is being done in JavaScript:

if (
    !CSS.supports("animation-timeline: foo") && 
    !window.matchMedia('(prefers-reduced-motion: reduce)').matches
   ) {
     // Do fancy stuff
}

I’m not 100% if it’s best to test for no-preference or the opposite of reduce. Either way, the trick in CSS is to wrap anything you’re going to do with @scroll-timeline and animation-timeline in an @supports test (in case you want to do something different otherwise) and then wrap that in a preference test:

@media (prefers-reduced-motion: no-preference) {

    @supports (animation-timeline: works) {

      /* Do fancy stuff */

    }

}

Here’s a demo of that, with all the real credit to Bramus here for getting it going.

Ooo and ya know what? The CSS gets nicer should @when land as a feature:

@when supports(animation-timeline: works) and media(prefers-reduced-motion: no-preference) {

} @else {

}

Notes on Reverse-Scrolling Columns With CSS Scroll-Timeline originally published on CSS-Tricks. You should get the newsletter and become a supporter.


This content originally appeared on CSS-Tricks and was authored by Chris Coyier


Print Share Comment Cite Upload Translate Updates
APA

Chris Coyier | Sciencx (2022-01-31T21:02:06+00:00) Notes on Reverse-Scrolling Columns With CSS Scroll-Timeline. Retrieved from https://www.scien.cx/2022/01/31/notes-on-reverse-scrolling-columns-with-css-scroll-timeline/

MLA
" » Notes on Reverse-Scrolling Columns With CSS Scroll-Timeline." Chris Coyier | Sciencx - Monday January 31, 2022, https://www.scien.cx/2022/01/31/notes-on-reverse-scrolling-columns-with-css-scroll-timeline/
HARVARD
Chris Coyier | Sciencx Monday January 31, 2022 » Notes on Reverse-Scrolling Columns With CSS Scroll-Timeline., viewed ,<https://www.scien.cx/2022/01/31/notes-on-reverse-scrolling-columns-with-css-scroll-timeline/>
VANCOUVER
Chris Coyier | Sciencx - » Notes on Reverse-Scrolling Columns With CSS Scroll-Timeline. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2022/01/31/notes-on-reverse-scrolling-columns-with-css-scroll-timeline/
CHICAGO
" » Notes on Reverse-Scrolling Columns With CSS Scroll-Timeline." Chris Coyier | Sciencx - Accessed . https://www.scien.cx/2022/01/31/notes-on-reverse-scrolling-columns-with-css-scroll-timeline/
IEEE
" » Notes on Reverse-Scrolling Columns With CSS Scroll-Timeline." Chris Coyier | Sciencx [Online]. Available: https://www.scien.cx/2022/01/31/notes-on-reverse-scrolling-columns-with-css-scroll-timeline/. [Accessed: ]
rf:citation
» Notes on Reverse-Scrolling Columns With CSS Scroll-Timeline | Chris Coyier | Sciencx | https://www.scien.cx/2022/01/31/notes-on-reverse-scrolling-columns-with-css-scroll-timeline/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.