对于jQuery相对来说比较新,而且有一点问题。以前我用.animate来动画我的菜单,当我向下滚动时,但我必须将其更改为fadeIn和fadeOut。这里是我的代码:用fadeIn/fadeOut代替.animate()
if($(this).scrollTop() > 100) {
bar.stop().animate({'top' : '0px'}, 1250);
} else {
bar.stop().animate({'top' : top}, 1250);
}
对于jQuery相对来说比较新,而且有一点问题。以前我用.animate来动画我的菜单,当我向下滚动时,但我必须将其更改为fadeIn和fadeOut。这里是我的代码:用fadeIn/fadeOut代替.animate()
if($(this).scrollTop() > 100) {
bar.stop().animate({'top' : '0px'}, 1250);
} else {
bar.stop().animate({'top' : top}, 1250);
}
你只需要调用fadeIn/fadeOut
你的元素
bar.fadeOut('slow');
或
bar.fadeIn('slow');
你也可以附加一个回调函数。欲了解更多信息,请参阅:
谢谢约翰的帮助。还有一个与此相关的问题,我如何设置淡入淡出的顶部位置,就像我在.animate中一样({'top':'0px'},1250); – user2060549 2013-02-12 05:29:12
if($(this).scrollTop() > 100) {
bar.stop().fadeOut();
} else {
bar.stop().fadeIn();
}
以供将来参考请到这里: http://api.jquery.com/fadeOut/
人是当你提供展示你做某种研究联系更加快乐。无论如何,欢呼声。
if($(this).scrollTop() > 100) {
bar.stop().fadeOut(function() { $(this).animate({'top' : '0px'}, 1250); }, "slow");
} else {
bar.stop().fadeIn(function() { $(this).animate({'top' : '0px'}, 1250); }, "slow");
}
你的问题含糊不清。但是你可以使用任何适合你的答案代码。另请参阅文档,因为他们在那里有示例。
也向我们展示您的html代码.. – bipen 2013-02-11 07:44:36
您是否使用动画来隐藏某些元素? – Musa 2013-02-11 07:47:15
当用户向下滚动页面时,一个条带在顶层菜单下滑动,之前我为该条带动画,但现在我必须淡入/淡出。 – user2060549 2013-02-11 10:31:13