问题解答原地址:https://stackoverflow.com/questions/13614112/using-scrollintoview-with-a-fixed-position-header
var node = 'select your element';
var yourHeight = 'height of your fixed header';
// scroll to your element
node.scrollIntoView(true);
// now account for fixed header
var scrolledY = window.scrollY;
if(scrolledY){
window.scroll(0, scrolledY - yourHeight);
}
本文介绍如何使用JavaScript在考虑固定头部元素的情况下,实现滚动到指定元素的视图。通过`scrollIntoView`函数配合窗口滚动位置调整,确保内容可见性。
4016

被折叠的 条评论
为什么被折叠?



