无法在滚动时实现淡入淡出?

时间:2016-09-23 07:50:41

标签: jquery html css

我有一个我想要制作的网站。当我到达某个div时,我想让div出现(淡出)然后当我滚过它时消失(淡出)。

<div id="div1">
    <p class="welcomePar3">Welcome to my website! Here you will find all information related to me. Feel free to browse around!</p>
    <div id="UWIMAGE">
        <img id="imageActual" src="img/uw.jpg">
    </div>
</div>
$('#div2').fadeInScroll();
$('#div2').fadeInScroll({
    minDistance: 75 * $(window).height() / 100
});

没有运气。我该怎么办?

1 个答案:

答案 0 :(得分:0)

您知道使用jQuery是否可以轻松准备文档,这是一个众所周知的事件。 这里有一个代码应该如何显示的示例:

// to wrap code around the jQuery document ready event
$(document).ready(function(){ /* stuff */ });

// or (shorthand for above)
$(function(){ /* stuff */ });

// so your code could look like this
$(function(){
    $('#div2').fadeInScroll();
});

请谨慎使用您的ID,在您使用的{js代码#div2中,但您的html已div1作为ID。

如果您转到插件页面(https://github.com/maugelves/FadeInScroll),则可以看到名为index.html的文件。你有一个如何的例子。

https://learn.jquery.com/using-jquery-core/document-ready/