基于滚动位置的不透明度 [英] Opacity based on scroll position
本文介绍了基于滚动位置的不透明度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
以下代码将使当scrollTop()超过400px时淡出转到顶部"按钮,效果很好,但是我还没有找到一种使它淡出的方法.顶部.
The following code, will make the "Go to top" button fade in when the scrollTop() is over 400px, that works fine, but i haven't found a way to make it fade out when i go back to the top.
$("#gototop").css("opacity", "0");
$(window).bind('scroll', function(){
if($(this).scrollTop() > 400) {
$("#gototop").animate({
opacity: 100,
}, 3400);
}
});
如果没有没有帮助,我又尝试了其他,但我的非忍者技能尝试了其他选项,但均无济于事.当滚动回到顶部时,关于如何使其淡出的任何想法?
An else after the if didn't help, i tried different options with my non-ninja skills but none worked. Any ideas on how to make it fade out when the scroll is back at the top?
谢谢.
推荐答案
我最终使用了名为航点来处理滚动位置.
I ended up using a plugin called waypoints to handle the scroll position.
这篇关于基于滚动位置的不透明度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文