Created
August 18, 2020 14:57
-
-
Save zachleat/a7393810acf7890e6bef6a34eaa7b78c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
html { | |
scroll-behavior: smooth; | |
} | |
@media (prefers-reduced-motion: reduce) { | |
html { | |
scroll-behavior: auto; | |
} | |
} |
Thanks for sharing @zachleat!
I made a quick example of this because I was in disbelief that "smooth scrolling" could be done in pure css.
demo: https://jsfiddle.net/adamculpepper/onu57cpj/5
Per some of the comments on the Tweet https://twitter.com/zachleat/status/1295737380738146304 I’ve switched to using:
@media (prefers-reduced-motion: no-preference) {
html {
scroll-behavior: smooth;
}
}
via https://twitter.com/g16n/status/1296799212445880321 and https://twitter.com/ericwbailey/status/1295741897483464705
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Found via @netlify repo for https://jamstackconf.com/