我正在尝试使用
<a href="#target">Details</a>
<div id="target">asd...</div>
但我也有顶部弹出菜单。所以它位于菜单后面。
是否可以编写 JavaScript(而且我已经在我的模板上使用 bootstrap 和 jquery 库)转到 #target - 100px
提前致谢
最佳答案
从未尝试过,但类似的东西应该有效。
$('html, body').animate({
scrollTop: $("#elementtoScrollToID").offset().top - 100
}, 1000); // this is the time in millisecond of the animation
关于javascript - 我怎样才能滚动到#target - 100px?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16510353/