Css Smooth Scroll Code Example
Example 1: smooth scroll css html { scroll-behavior: smooth; } /* No support in IE, or Safari You can use this JS polyfill for those */ http://iamdustan.com/smoothscroll/ Example 2: how to smooth scroll in javascript window.scrollTo({ top: 900, behavior: 'smooth' }) Example 3: smooth scroll html < script src = " https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js " > </ script > < script > $ ( document ) . ready ( function ( ) { // Add smooth scrolling to all links $ ( "a" ) . on ( 'click' , function ( event ) { // Make sure this.hash has a value before overriding default behavior if ( this . hash !== "" ) { // Prevent default anchor click behavior event . preventDefault ( ) ; // Store hash var hash = this . hash ; // Using jQuery's animate() method to add smooth page scroll // The optional number (800) specifies the number of milliseconds it