Stopping a CSS3 Animation on last frame

前端 未结 8 1237
伪装坚强ぢ
伪装坚强ぢ 2020-11-22 04:48

I have a 4 part CSS3 animation playing on click - but the last part of the animation is meant to take it off the screen.

However, it always goes back to its origin

8条回答
  •  别那么骄傲
    2020-11-22 04:57

    The best way seems to put the final state at the main part of css. Like here, i put width to 220px, so that it finally becomes 220px. But starting to 0px;

    div.menu-item1 {
      font-size: 20px;
      border: 2px solid #fff;
      width: 220px;
      animation: slide 1s;
      -webkit-animation: slide 1s; /* Safari and Chrome */
    }
    @-webkit-keyframes slide { /* Safari and Chrome */
      from {width:0px;}
      to {width:220px;}
    }  
    

提交回复
热议问题