jey*_*eyy 6 javascript scroll behavior motion parallax
网站上修改后的滚动行为是如何制作的?我想完成加速滚动行为,如您在示例中所见。所以你以一定的速度滚动,当你放手后,页面会自动滚动一点,减慢并停止。
不幸的是,我绝对没有为您提供代码的基础,我希望您仍然可以帮助我。也许你可以推荐我一些js插件?
小智 5
您有两种方法可以实现这一目标。你可以使用CSS
html { scroll-behavior: smooth; }
Run Code Online (Sandbox Code Playgroud)
或者你可以使用 JavaScript:
// 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'
})
Run Code Online (Sandbox Code Playgroud)
您可以在此处阅读更多内容并找到更多示例:https ://css-tricks.com/snippets/jquery/smooth-scrolling/
| 归档时间: |
|
| 查看次数: |
25660 次 |
| 最近记录: |