我使用以下jQuery函数滚动到单个页面站点中的div ID:
$('a').click(function(){
    var top = $('html').find($(this).attr('href')).offset().top;
    $('html, body').animate({scrollTop: top},1500, 'easeInOutCubic');
    return false;
});
Run Code Online (Sandbox Code Playgroud)
有没有办法使用jQuery在每个div上方添加100像素的空间?
我在浏览器窗口的顶部有一个固定的位置菜单,滚动到时需要div保持在菜单下方.
不确定我的问题是否正确,但听起来很容易实现:
...
var top = $('html').find($(this).attr('href')).offset().top - 100;
...
Run Code Online (Sandbox Code Playgroud)