需要jquery scrollTop帮助吗

需要jquery scrollTop帮助吗,jquery,scroll,Jquery,Scroll,我的代码是: $('html, body').stop().animate({scrollTop : $('#current').offset().top}, 300, easeInOutExpo); 它所做的是将项目(#current)滚动到窗口顶部 我想让它从顶部向下滚动项目至-100px 我怎样才能做到这一点?请帮忙。谢谢。试试这个: $('html, body').stop().animate({ scrollTop: $('#current').offset().top - 10

我的代码是:

$('html, body').stop().animate({scrollTop : $('#current').offset().top}, 300, easeInOutExpo);
它所做的是将项目(#current)滚动到窗口顶部
我想让它从顶部向下滚动项目至-100px
我怎样才能做到这一点?请帮忙。谢谢。

试试这个:

$('html, body').stop().animate({
  scrollTop: $('#current').offset().top - 100
}, 300, easeInOutExpo);
获取
#current
元素的当前顶部,并从该值中再提取100像素-将
#current
元素从窗口顶部保留100px