JavaScript将页面scroll滑动到屏幕特定位置

参考这个两个页面的做法,总结而言,scrolltoview函数

 

页面内跳转到指定div的几种方法(锚点、hash、animate、scrollIntoView)_I大俊-CSDN博客: https://blog.csdn.net/hope_It/article/details/82586481,使用scrolltoview是最佳的

 

备注:也有其他方式:javascript - Scroll Automatically to the Bottom of the Page - Stack Overflow: https://stackoverflow.com/questions/11715646/scroll-automatically-to-the-bottom-of-the-page,使用window.scrollTo(0, document.querySelector(className).scrollHeight),window.scrollto但是会存在一些问题:如果页面长度不够,会导致无法正确显示想要目标位置。

posted @ 2022-01-17 16:14  盒内有盖请小心打开  阅读(468)  评论(0)    收藏  举报