js实现平滑滚动

 原生JS实现页面平滑滚动

window.scroll({
    top: [number] y,
    left: [number] x,
    behavior: [stirng] behavior
})

//behavior 三个取值: auto,instant(瞬间移动),smooth(平滑移动)

jQuery实现平滑移动

function(){
    $('html,body').animate({scrollTop: '0px'}, 800);    //滑动至顶部
}

猜你喜欢

转载自blog.csdn.net/qq_37728271/article/details/85114266