Answers for "how to give smooth scrolling in html"

12

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/
Posted by: Guest on March-18-2020
1

smooth scrolll to id js

// handle links with @href started with '#' only
$(document).on('click', 'a[href^="#"]', function(e) {
    // target element id
    var id = $(this).attr('href');

    // target element
    var $id = $(id);
    if ($id.length === 0) {
        return;
    }

    // prevent standard hash navigation (avoid blinking in IE)
    e.preventDefault();

    // top position relative to the document
    var pos = $id.offset().top;

    // animated top scrolling
    $('body, html').animate({scrollTop: pos});
});
Posted by: Guest on January-04-2021
0

scroll smooth css

html {
  scroll-behavior: smooth;
}
Posted by: Guest on December-12-2020

Code answers related to "Javascript"

Browse Popular Code Answers by Language