如何在点击时向下滚动一定距离 jQuery

How to scroll down a certain distance on click jQuery

当我点击带有动画的按钮到一定距离时,我试图向下滚动页面,目前,我可以向下滚动到某个元素,但这不是我想要的,我想要向下滚动到一定距离(以像素为单位)。

我尝试了很多变体,但它们似乎对我的情况不起作用,至少不是我想要的那样。

无论如何,这是代码:

$(document).ready(function(){
   $('.next_section').click(function(){
        $('html, body').animate({
            scrollTop: $('.img_div').offset().top
        }, 1000);
   }); 
}

to a certain distance

我假设距离以像素为单位?

这会向下滚动 150 像素:

var y = $(window).scrollTop();  //your current y position on the page
$(window).scrollTop(y+150);

@therealbischero(谢谢!)在评论中提到了我的回答中遗漏的部分,如何使其平滑滚动:

var y = $(window).scrollTop();
 $('html, body').animate({ scrollTop: y + 150 })