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