📌  相关文章
📜  按 id 中心滚动到元素 - Javascript 代码示例

📅  最后修改于: 2022-03-11 15:01:44.910000             🧑  作者: Mango

代码示例1
// scroll to specified element. accepts params to choose scroll type, position on page etc
document.getElementById("divFirst").scrollIntoView();
// scrolls smoothly and centers div:
document.getElementById("divFirst").scrollIntoView({behavior: "smooth", block: "center"});
// for all param options visit developer.mozilla.org/en-US/docs/Web/API/Element/scrollIntoView