[英]Fade in on scroll and fade out on scroll
I'm new to this stuff. 我是新手。
I'm using this to make a div appear on scroll and to make it disappear when I scroll further. 我正在使用它使div出现在滚动条上,并在我进一步滚动时使其消失。
It's working pretty good. 运行良好。 It fade's out when I pass 1750. But on page load the div is already there.
当我通过1750时,它消失了。但是在页面加载时,div已经存在。 It should appear when I scroll past 1500.
当我滚动到1500时,它应该会出现。
What I need is the div be visible between 1500 and 1750. Hope you can help! 我需要的是1500和1750之间可见的div。希望您能提供帮助!
<script type="text/javascript">
$(document).scroll(function () {
var x = $(this).scrollTop();
if (x > 1500) {
$('#form_1_container').fadeIn(150);
} if (x > 1750) {
$('#form_1_container').fadeOut(150);
}
});
</script>
This is the site = http://www.stilld.nl/brrreuk/ 这是网站= http://www.stilld.nl/brrreuk/
You can see if you scroll, that the div appears and disappears. 您可以查看是否滚动,div会消失。 But then it start to pulse...
但是随后开始脉动...
I'm using display=none on my div. 我在div上使用display = none。
You can try this 你可以试试这个
$(document).scroll(function () {
var x = $(this).scrollTop();
if (x > 1500 && x < 1750) {
$('#form_1_container').stop().fadeIn(150);
}
else{
$('#form_1_container').stop().fadeOut(150);
}
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.