滚动后淡入div [英] Fade in div after scrolling
本文介绍了滚动后淡入div的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我需要能够根据用户滚动的px数量淡入/淡出div.这是我现有的jQuery.我可以切换其视图,但我想淡化该切换.什么是正确的方法?
I need to be able to fadein/fadeout a div depending on the amount of px scrolled by the user. Here is the existing jquery I have. I can toggle its view but i'd like to fade that toggle. What is the correct method here?
$("#subOverlay").hide();
$(window).bind('scroll', function(){
$("#subOverlay").toggle($(this).scrollTop() > 520);
});
谢谢
推荐答案
可以按照以下步骤进行操作:
It could be done as follows:
$(window).bind("scroll", function() {
if ($(this).scrollTop() > 520) {
$("#subOverlay").fadeIn();
} else {
$("#subOverlay").stop().fadeOut();
}
});
演示: http://jsfiddle.net/ZHkY8/
这篇关于滚动后淡入div的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文