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

<button id="btn">Запустити анімацію</button>

<hr>

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

#btn {
  cursor: pointer;
  width: 250px;
  text-align: center;
  padding: 6px 12px;
  font-size: 19px;
  display: inline-block;
}

@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;
  width: 125px;
  text-align: center;
  color: #fff;
  font-size: 15px;
  border: 2px solid rgba(255, 255, 255, .45);
  
  animation-name: animate;
  animation-duration: 1.25s;
  animation-timing-function: ease-in;
  animation-delay: 0s;
  animation-direction: alternate;
  animation-play-state: paused;
}

.block-1 {
  animation-iteration-count: 1;
}
.block-2 {
  animation-iteration-count: 4;
}
.block-3 {
  animation-iteration-count: 10;
}
.block-4 {
  animation-iteration-count: infinite;
}
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';
  }
}

External CSS

This Pen doesn't use any external CSS resources.

External JavaScript

This Pen doesn't use any external JavaScript resources.