[英]Fade out at specific scroll position
I can now fade in a at a specific scroll height. 现在,我可以以特定的滚动高度淡入。 But now I also want to fade out a at specific scroll height.
但是现在我也想淡出特定滚动高度。 My code for the fade out:
我的淡出代码:
<script type="text/javascript">
window.onscroll = function()
{
if( window.XMLHttpRequest ) {
if (document.documentElement.scrollTop > 25 || self.pageYOffset > 25) {
$('.pulse').css('display','block');
} else if (document.documentElement.scrollTop < 25 || self.pageYOffset < 25) {
$('.pulse').css('display','none');
}
}
And in css: 并在CSS中:
display: none;
How can I fade out a at specific height? 如何淡出特定高度的光?
Thanks for the help 谢谢您的帮助
You can use fadeIn() and fadeOut() functions provided by jQuery: 您可以使用jQuery提供的fadeIn()和fadeOut()函数:
//to show
$('.pulse').fadeIn(1000);
//to hide
$('.pulse').fadeOut(1000);
Docs of these functions: 这些功能的文档:
http://api.jquery.com/fadeout/ http://api.jquery.com/fadein/ http://api.jquery.com/fadeout/ http://api.jquery.com/fadein/
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.