dual animation test

by Travis Almand

HTML

<div id="container">
  <div id="ball_container"><div id="ball"></div></div>
</div>

CSS

#container {
  border: 1px solid black;
  bottom: 0;
  height: 200px;
  left: 0;
  margin: auto;
  position: absolute;
  right: 0;
  top: 0;
  width: 100px;
}

#ball_container,
#ball {
  height: 20px;
  left: 0;
  position: absolute;
  top: 0;
  width: 20px;
}

#ball_container {
  animation: 3s linear infinite ball-container;
}

#ball {
  animation: 3s linear infinite ball;
  border: 1px solid blue;
  border-radius: 50%;
}

@keyframes ball-container {
  0% {
    left: calc(50% - 10px);
  }
  12.5% {
    left: calc(100% - 20px);
  }
  25% {
    left: calc(50% - 10px);
  }
  37.5% {
    left: 0;
  }
  50% {
    left: calc(50% - 10px);
  }
  62.5% {
    left: calc(100% - 20px);
  }
  75% {
    left: calc(50% - 10px);
  }
  87.5% {
    left: 0;
  }
  100% {
    left: calc(50% - 10px);
  }
}

@keyframes ball {
  0% {
    top: 0;
  }
  12.5% {
    top: 45px;
  }
  25% {
    top: 90px;
  }
  37.5% {
    top: 135px;
  }
  50% {
    top: 180px;
  }
  62.5% {
    top: 135px;
  }
  75% {
    top: 90px;
  }
  87.5% {
    top: 45px;
  }
  100% {
    top: 0;
  }
}