Make a pause during infinite CSS3 animation

前端 未结 3 1673
星月不相逢
星月不相逢 2021-01-11 09:40

I try to make an animation that run every 3 seconds without JavaScript. My animation\'s duration is 1 second.

I\'m only able to wait 3seconds the fi

3条回答
  •  無奈伤痛
    2021-01-11 10:26

    It seems like the only way to achieve this is to extend the animation so that it lasts 4s instead of 1s. Then you could delay the animation by animating from 75% to 100% (rather than 0% to 100%).

    In doing so, there is essentially an artificial delay in the animation itself. You just have to do the math to figure out how long this delay is in correlation with the total length of the animation itself.

    Updated Example

    .face.back {
          display: block;
          transform: rotateY(180deg);
    }
    
    .face.back {
        -webkit-animation: BackRotate 4s linear infinite;
        animation: BackRotate 4s linear infinite;
    }
    
    .face.front {
        -webkit-animation: Rotate 4s linear infinite;
        animation: Rotate 4s linear infinite;
    }
    
    
    @-webkit-keyframes Rotate {
        75% {-webkit-transform:rotateY(0deg);}
        100% {-webkit-transform:rotateY(360deg);}
    }
    @-webkit-keyframes BackRotate {
        75% {-webkit-transform:rotateY(180deg);}
        100% {-webkit-transform:rotateY(540deg);}
    } 
    @keyframes Rotate {
        75% {-webkit-transform:rotateY(0deg);}
        100% {-webkit-transform:rotateY(360deg);}
    }
    @keyframes BackRotate {
        75% {-webkit-transform:rotateY(180deg);}
        100% {-webkit-transform:rotateY(540deg);}
    }
    

提交回复
热议问题