当前位置:   article > 正文

js平滑滚动元素进入视图_smoothscroll.min.js

smoothscroll.min.js

将调用它的元素平滑地滚动到浏览器窗口的可见区域。

  • 用于Element.scrollIntoView()滚动元素。
  • 用于{ behavior: 'smooth' }平滑滚动。
  1. const smoothScroll = element =>
  2. document.querySelector(element).scrollIntoView({
  3. behavior: 'smooth'
  4. });
  1. smoothScroll('#fooBar'); // scrolls smoothly to the element with the id fooBar
  2. smoothScroll('.fooBar');
  3. // scrolls smoothly to the first element with a class of fooBar
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/花生_TL007/article/detail/295419
推荐阅读
相关标签
  

闽ICP备14008679号