我使用这样的 anchor 元素:
<div class="my_centered" id="index_scroll_down_button">
<a href="#" onclick="smooth_scroll('#intro')">
<img src="/static/img/scroll-down-icon.png">
</a>
</div>
<div class="indexcontainer container" id="intro">
</div>
smooth_scroll
函数定义为:
function smooth_scroll(target){
$('html, body').animate({
scrollTop: $(target).offset().top - 60
}, 800);
}
这种方法在 Safari 上运行良好,但在 Chrome 上似乎不起作用? 这是我的 CSS:
#index_scroll_down_button {
position: absolute;
bottom: 0px;
left: 50%;
margin-left: -30px;
}
最佳答案
Animate scrolltop 在 firefox 中对我有效,但在 chrome 和 edge 中无效。以下 css 导致了问题:
html, body {
overflow-x: hidden;
}
关于javascript - 动画 scrollTop 在 Chrome 上不起作用?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43552870/