在Scroll上堆叠Div

时间:2012-10-08 01:20:58

标签: javascript jquery css html scrolltop

我试图在滚动上有一个div堆叠在另一个上面。现在,第二个div不透明度设置为0,一旦达到第二个div的底部,不透明度变为1.我如何调整此值,以便当滚动到达div的顶部时不透明度变为1?

 $(document).ready(function() {

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

        /* Check the location of each desired element */
        $('#thrillercontainer').each( function(i){

            var bottom_of_object = $(this).position().top + $(this).outerHeight();
            var bottom_of_window = $(window).scrollTop() + $(window).height();

            /* If the object is completely visible in the window, fade it it */
            if( bottom_of_window > bottom_of_object ){

                $(this).animate({'opacity':'1'},100);
                $('#horrorcontainer').slideUp(100);

            }

0 个答案:

没有答案