Greetings!
Do you want to give your site that cool smooth scroll when someone clicks a link?
So, lets say you have an awesome page with different sections. You have several ways for allowing the user to get to them. Here are some examples:
Here we go with the CSS way to get that smooth auto-scroll:
html {
scroll-behavior: smooth;
}Replacing smooth with auto gives you the default insta-jump behavior.
Vestibular disorders arise when the parts of the inner ear and brain that process the sensory information involved with controlling balance and eye movement get damaged.
Users with this disorders may suffer from motion sickness, which can make the experience of browsing the web quite unpleasent for them.
As stated in MDN, you should use a CSS prefers-reduced-motion media query to disable smooth scrolling to account for users that have set their browsers to reduced motion:
html {
scroll-behavior: smooth;
}
@media (prefers-reduced-motion: reduce) {
html {
scroll-behavior: auto;
}
}This CSS property is supported in Chrome, Firefox and Opera. As of the date of publication of this blog post, it is not supported in Safari, Edge nor Internet Explorer.
Cheers, have a good one!