赞
踩
将调用它的元素平滑地滚动到浏览器窗口的可见区域。
Element.scrollIntoView()
滚动元素。{ behavior: 'smooth' }
平滑滚动。- const smoothScroll = element =>
- document.querySelector(element).scrollIntoView({
- behavior: 'smooth'
- });
- smoothScroll('#fooBar'); // scrolls smoothly to the element with the id fooBar
- smoothScroll('.fooBar');
- // scrolls smoothly to the first element with a class of fooBar
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。