我将在页面左侧设置一个粘性的导航目录,以便与页面一起滚动,并使用Jquery将其与页面向下滚动。我有绝对位置150 is从顶部,但当我使用Jquery时,它需要导航到页面顶部将跳转到顶部:150 is位置,但我如何使它激活一旦它从顶部到达150 is,这样就不再有跳转。
您可以在http://stormable.com/heroes/malfurion/上查看这个
如果你注意到当你向上滚动时,右边的跳转链接必须在它激活固定位置之前点击页面的顶部。
我假设我必须更改脚本中的y >=顶部,但我不确定如何更改它以从顶部激活150 it。
我使用的Jquery是
$(document).ready(function () {
var top = $('#jump-list').offset().top - parseFloat($('#jump-list').css('marginTop').replace(/auto/, 0));
$(window).scroll(function (event) {
// what the y position of the scroll is
var y = $(this).scrollTop();
// whether that's below the form
if (y >= top) {
// if so, ad the fixed class
$('#jump-list').addClass('fixed');
} else {
// otherwise remove it
$('#jump-list').removeClass('fixed');
}
});
});发布于 2013-11-16 21:09:55
为什么不直接将顶部变量更改为:
var top = $('#jump-list').offset().top - 100https://stackoverflow.com/questions/20023846
复制相似问题