Stop animation and start transition on hover

前端 未结 6 1348
误落风尘
误落风尘 2021-01-07 19:05

I have a link that\'s running an infinite animation with the background color. I want to stop the animation and transition into a different background color on hover.

<
6条回答
  •  栀梦
    栀梦 (楼主)
    2021-01-07 19:13

    For those who are interested by animation slide with stop between 2 images

    var NumImg = 1; //Img Number to show
    var MaxImg = 3; //How many Img in directory ( named 1.jpg,2.jpg ...)
    
    function AnimFond() {
      NumImg = NumImg> MaxImg ? 1 : NumImg +=1;
      var MyImage = "http://startinbio.com/Lib/Images/Fond/" + NumImg + ".jpg";
      $("#ImgFond1").attr("src", MyImage);
      $("#ImgFond2").fadeOut(3000, function() {
        $("#ImgFond2").attr("src", MyImage);
        $("#ImgFond2").fadeIn(1);
      });
    }
    
    setInterval("AnimFond()", 10000); //delay between 2 img
    #AnimFond {
      position: fixed;
      height: 100%;
      width: 100%;
      margin: 0 0 0 -8;
    }
    
    #AnimFond img {
      position: absolute;
      left: 0;
      height: 100%;
      width: 100%;
    }
    
    

提交回复
热议问题