scrollIntoView()除了safari外都支持
scrollIntoViewIfNeeded(centerIfNeeded) 兼容Safari
元素滚动到浏览器窗口的可见区域内
scrollIntoView
scrollIntoView()
scrollIntoView(alignToTop)
scrollIntoView(scrollIntoViewOptions)
document.scrollIntoView() // 默认滚动到可视区域顶部
docuemnt.scrollIntoView(true/false) //true与可视区域顶部对齐;false与可视区域底部对齐
docuemnt.scrollIntoView({behavior: "smooth", block: "end", inline: "nearest"})
// behavior定义过渡动画,可选值为auto/smooth,默认值为auto
// block 定义垂直对齐方式,可选值为start/center/end/nearest,默认值start
// inline 定义水平对齐方式,默认值为start/center/end/nearest,默认值nearest
document.scrollIntoView(true/false)
// true 可滚动祖先的可视区域居中对齐
// false 可滚动祖先的可见区域的最近边缘对齐