我使用此代码滚动到网站的水平中心。
function scrollCenter() {
scrollTo(($(document).width() - $(window).width()) / 2, 0);
}
如何获得动画滚动效果?
最佳答案
要设置动画的属性是 scrollLeft
。
$( 'html, body' ).animate({
scrollLeft: ($(document).width() - $(window).width()) / 2
}, 'slow' );
关于javascript - 用动画滚动到中心,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14374435/