jQuery fading two images without white

前端 未结 4 942
予麋鹿
予麋鹿 2020-12-19 20:19

I would like to fade image without white transfer between them.

HTML:

4条回答
  •  一向
    一向 (楼主)
    2020-12-19 21:05

    This should give you an idea:

    var c = 0,                  // Counter index
        $img = $('.image img'), // Get images
        n = $img.length;        // How many images?
    
    $img.eq(c).show();          // Show c one
    
    (function loop() {          // Recursive infinite loop
        $img.delay(1000).fadeOut(800).eq(++c%n).fadeIn(800, loop);
    }()); 
    .image{
      position:relative;
    }
    .image img{
      position:absolute;
      top:0px; 
      display:none;
    }
    
    

提交回复
热议问题