<p>Різні значення для <code>animation-direction</code> у дії:</p>


<hr>

<div class="wrapper">
  <div class="block block-1">
    <span>normal</span>
  </div>
  <div class="block block-2">
    <span>reverse</span>
  </div>
  <div class="block block-3">
    <span>alternate</span>
  </div>
  <div class="block block-4">
    <span>alternate-reverse</span>
  </div>
</div>
body {
  padding: 36px;
  text-align: center;
  font-family: monospace;
  font-size: 17px;
  color: #222;
  line-height: 1.45; 
}


@keyframes animate {
  
  from { 
    margin-top: 50px; 
  }
  
  to   { 
    margin-top: 100px; 
  }
  
}

.wrapper {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
}

.block {
  background-color: red;
  padding: 26px 8px;
/*   height: 125px; */
  width: 125px;
  text-align: center;
  color: #fff;
  font-size: 15px;
  border: 2px solid rgba(255, 255, 255, .45);
  animation: animate 1.75s linear 2.5s infinite normal;
}

.block-1 {
  animation-direction: normal;
}
.block-2 {
  animation-direction: reverse;
}
.block-3 {
  animation-direction: alternate;
}
.block-4 {
  animation-direction: alternate-reverse;
}
// var blocks = document.getElementsByClassName('block');
// var btn = document.getElementById('btn');

// btn.onclick = function() {
//   for (var i = 0; i < blocks.length; i++) {
//     blocks[i].style.animationPlayState = 'running';
//   }
//   btn.innerHTML = 'Зупинити анімацію';
// }

External CSS

This Pen doesn't use any external CSS resources.

External JavaScript

This Pen doesn't use any external JavaScript resources.