<div class="container">
  <p>
    The animation iterates infinitely, and the animation-direction is set to <code>alternate</code>.
  </p>
  <div class="element element-1"></div>
  <p>
    The animation iterates infinitely, and the animation-direction is set to its default value <code>normal</code>.
  </p>
  <div class="element element-2"></div>
</div>
body {
  background-color: #F5F5F5;
  color: #555;
  font-size: 1.1em;
  font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
}

hr {
  margin: 50px 0;
}

.container {
  margin: 50px auto;
  max-width: 700px;
  padding: 30px;
  border: 1px solid #aaa;
  background-color: white;
}

.element {
  width: 50px;
  height: 50px;
  position: relative;
  top: 0;
  left: 0;
  -webkit-animation-name: zigzag;
  animation-name: zigzag;
  -webkit-animation-duration: 3s;
  animation-duration: 3s;
  -webkit-animation-timing-function: linear;
  animation-timing-function: linear;
}

.element-1 {
  background-color: #009966;
  -webkit-animation-iteration-count: infinite;
  animation-iteration-count: infinite;
  -webkit-animation-direction: alternate;
  animation-direction: alternate;
}

.element-2 {
  background-color: purple;
  -webkit-animation-iteration-count: infinite;
  animation-iteration-count: infinite;
  -webkit-animation-direction: normal;
  animation-direction: normal;
}

@-webkit-keyframes zigzag {
  from {
    left: 0;
    top: 0;
  }
  15% {
    left: 50px;
    top: -50px;
  }
  30% {
    left: 100px;
    top: 0;
  }
  45% {
    left: 150px;
    top: -50px;
  }
  60% {
    left: 200px;
    top: 0;
  }
  75% {
    left: 250px;
    top: -50px;
  }
  100% {
    left: 300px;
    top: 0;
  }
}

@keyframes zigzag {
  from {
    left: 0;
    top: 0;
  }
  15% {
    left: 50px;
    top: -50px;
  }
  30% {
    left: 100px;
    top: 0;
  }
  45% {
    left: 150px;
    top: -50px;
  }
  60% {
    left: 200px;
    top: 0;
  }
  75% {
    left: 250px;
    top: -50px;
  }
  100% {
    left: 300px;
    top: 0;
  }
}