在滚动

时间:2015-11-23 09:04:43

标签: javascript jquery html css

我一直在研究并找到了一些关于这个主题的内容,但在我的情况下没有任何东西可用,而且往往很难让我实施。

当你开始在我的主页上滚动时,我想让一个div淡入淡出。它应该融入我的标题后面,我将我的标识作为一个固定的div。

“John Polo”(标题标识)固定在顶部,滚动时应该让它的背景div淡入,我试图用这两张图片给你一个想法:)

打开网页时(顶部) when opening webpage (top)

当你开始滚动时 when you begin to scroll

1 个答案:

答案 0 :(得分:0)

试试这个。

/* Every time the window is scrolled ... */
jQuery(window).scroll( function(){

    /* Check the location of element */
    jQuery('.hideme').each( function(i){

        var logo = jQuery(this).outerHeight();
        var position = jQuery(window).scrollTop();
        /* fade out */
        if( position > logo  ){

            jQuery(this).animate({'opacity':'0'},500);

        }else{ jQuery(this).animate({'opacity':'1'},500);}

    }); 

});