how to smooth scroll in html code example
Example 1: smooth scroll css
html {
scroll-behavior: smooth;
}
http:
Example 2: smooth scroll
window.scroll({
top: 2500,
left: 0,
behavior: 'smooth'
});
window.scrollBy({
top: 100,
left: 0,
behavior: 'smooth'
});
document.querySelector('.hello').scrollIntoView({
behavior: 'smooth'
});
Example 3: smooth scroll
$('a[href*=#]:not([href=#])').on('click', function() {
if (location.pathname.replace(/^\
var target = $(this.hash);
target = target.length ? target : $('[name=' + this.hash.slice(1) + ']');
if (target.length) {
$('html,body').animate({
scrollTop: (target.offset().top - 40)
}, 1000);
return false;
}
}
});
Example 4: scroll smooth css
html {
scroll-behavior: smooth;
}