Fade in element on scroll down using css

前端 未结 4 974
面向向阳花
面向向阳花 2020-12-28 22:40

Example: http://www.chartjs.org/

When scrolling down each article shows up when it gets in the view-port of the browser. The css is

         


        
4条回答
  •  甜味超标
    2020-12-28 22:47

    Demo Fiddle

    Do you want something like this ?

       $(window).scroll(function () {
    
            /* Check the location of each desired element */
            $('.article').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'
                    }, 500);
    
                }
    
            });
    
        });
    

提交回复
热议问题