text Smooth Scroll CSS / JS

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了text Smooth Scroll CSS / JS相关的知识,希望对你有一定的参考价值。



https://css-tricks.com/snippets/jquery/smooth-scrolling/

CSS ONLY:
html {
  scroll-behavior: smooth;
}


JS, no libraries
// Scroll to specific values
// scrollTo is the same
window.scroll({
  top: 2500, 
  left: 0, 
  behavior: 'smooth'
});

// Scroll certain amounts from current position 
window.scrollBy({ 
  top: 100, // could be negative value
  left: 0, 
  behavior: 'smooth' 
});

// Scroll to a certain element
document.querySelector('.hello').scrollIntoView({ 
  behavior: 'smooth' 
});










以上是关于text Smooth Scroll CSS / JS的主要内容,如果未能解决你的问题,请参考以下文章

JavaScript - window.scroll( behavior: 'smooth' ) 在 Safari 中不起作用

javascript Smooth Anchor Scroll

javascript jQuery Smooth Scroll

javascript jQuery Smooth Scroll

javascript jQuery Smooth Scroll

javascript jQuery Smooth Scroll