<div class="ball"></div>
<div class="ball"></div>
<div class="ball"></div>
<div class="ball"></div>

<button>播放动画</button>

<button>重置动画</button>
body {
  padding: 15px;
  text-align: center;
}
.ball {
  width: 100px;
  height: 100px;
  border-radius: 100%;
  background-color: #29B4F0;
  margin: 5px;
  position: relative;
  
  &:before {
    content:"";
    position: absolute;
    top: 50%;
    left: 50%;
    color: #fff;
    transform: translate(-50%,-50%);
  }
  
  &:nth-child(1):before {
    content:"none";
  }
  &:nth-child(2):before {
    content:"forwards";
  }
  &:nth-child(3):before {
    content:"backwards";
  }
  &:nth-child(4):before {
    content:"both";
  }
}
.doAnim:nth-child(1) {
  animation: move1 2s ease 1s none;
}
  
.doAnim:nth-child(2) {
  animation: move1 2s ease 1s forwards;
}
.doAnim:nth-child(3) {
  animation: move1 2s ease 1s backwards;
}
.doAnim:nth-child(4) {
  animation: move1 2s ease 1s both;
}
@keyframes move1 {
  0% {
    background: pink;
    transform: translate3d(0,0,0);
  }
  100% {
    transform: scale(1.5) translate3d(300%, 0, 0);
  }
}


button {
  border-radius: 5px;
  padding: 10px 20px;
  font-size: 14px;
  text-decoration: none;
  margin: 20px;
  color: #fff;
  position: relative;
  display: inline-block;
  border: none 0;
  
  &:active,
  &:focus{
    transform: translate(0px, 5px);
    box-shadow: 0px 1px 0px 0px;
    outline: none;
  }
  &:nth-of-type(1) {
    background-color: #55acee;
    box-shadow: 0px 5px 0px 0px #3C93D5;
    
    &:hover {
      background-color: #6FC6FF;
    }
  }
  &:nth-of-type(2) {
    background-color: #9b59b6;
    box-shadow: 0px 5px 0px 0px #82409D;
    
    &:hover {
      background-color: #B573D0;
    }
  }
}
View Compiled
var start = document.querySelectorAll('button')[0],
    reset = document.querySelectorAll('button')[1],
    ball = document.querySelectorAll('.ball');

start.addEventListener('click', function () {
  ball.forEach(function(name) {
    name.classList.add('doAnim');
  })
}, false);

reset.addEventListener('click', function () {
  ball.forEach(function(name) {
    name.classList.remove('doAnim');
  })
}, false);

External CSS

This Pen doesn't use any external CSS resources.

External JavaScript

This Pen doesn't use any external JavaScript resources.