淡出滚动 [英] Fade Out On Scroll

查看:119
本文介绍了淡出滚动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚接触JQUERY,正在寻找正确方向的点.

I'm relatively new to JQUERY and I'm looking for a point in the right direction.

如何实现滚动淡入效果?

How do I achieve a fade on scroll effect?

类似于 http://fearthegrizzly.com/ http://davegamache.com

理想情况下,我希望可以选择将要淡入淡出的任何图像拖放到div中.如果可能的话.

Ideally I'd like the option to drop whatever image I want to fade out into a div. If that's possible.

也许值得一提的是我想在Cargo Collective上实现这一点.

It's probably worth mentioning I want to implement this on Cargo Collective.

谢谢

推荐答案

提示问题的技巧:不要只是告诉我们您想要什么.我们不是在这里为您做您的工作.向我们展示您尝试过的内容,以便我们进行修复.

Tip for asking question: Don't just tell us what you want. We're not here to do your work for you. Show us what you've tried so we can help fix it.

话虽如此,这是一个开始...

That being said, this is a start...

当窗口的滚动顶部位置大于20px时,它将使div淡出;当您向上滚动时,将其向后淡入.

When the window's scroll top position is greater than 20px, it fades a div out, when you scroll back up, it fades it back in.

$(window).scroll(function(){
   if($(window).scrollTop()<20){
         $('.fader').stop(true,true).fadeIn("slow");
   } else {
         $('.fader').stop(true,true).fadeOut("slow");
   }
});

演示

这篇关于淡出滚动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆