animation-iteration-count



значения свойства:


  • number
  • infinite



css/style.css
  • * {
  •  margin: 0;
  •  padding: 0;
  • }
  •  
  • .main {
  •  height: 600px;
  •  width: 900px;
  •  position: absolute;
  •  top: 50%;
  •  left: 50%;
  •  margin-top: -300px;
  •  margin-left: -450px;
  • }
  •  
  • .wrapper {
  •  width: 33.3%;
  •  height: 100%;
  •  float: left;
  • }
  •  
  • #div1, #div2, #div3 {
  •  height: 100px;
  •  width: 100px;
  •  float: left;
  •  position: relative;
  •  top: 50%;
  •  left: 50%;
  •  margin-top: -50px;
  •  margin-left: -50px;
  •  animation-duration: 3s;
  •  -moz-animation-duration: 3s;
  •  -o-animation-duration: 3s;
  •  -webkit-animation-duration: 3s;
  • }
  •  
  • #div1 {
  •  animation-name: anim1;
  •  -moz-animation-name: anim1;
  •  -o-animation-name: anim1;
  •  -webkit-animation-name: anim1;
  •  animation-iteration-count: 1;
  •  -moz-animation-iteration-count: 1;
  •  -o-animation-iteration-count: 1;
  •  -webkit-animation-iteration-count: 1;
  • }
  •  
  • @keyframes anim1 {
  •  from {
  •   background-color: #3BA9DE;
  •  }
  •  to {
  •   top: 80px;
  •   left: -10px;
  •   background-color: #A3E61D;
  •  }
  • }
  •  
  • @-moz-keyframes anim1 {
  •  from {
  •   background-color: #3BA9DE;
  •  }
  •  to {
  •   top: 80px;
  •   left: -10px;
  •   background-color: #A3E61D;
  •  }
  • }
  •  
  • @-o-keyframes anim1 {
  •  from {
  •   background-color: #3BA9DE;
  •  }
  •  to {
  •   top: 80px;
  •   left: -10px;
  •   background-color: #A3E61D;
  •  }
  • }
  •  
  • @-webkit-keyframes anim1 {
  •  from {
  •   background-color: #3BA9DE;
  •  }
  •  to {
  •   top: 80px;
  •   left: -10px;
  •   background-color: #A3E61D;
  •  }
  • }
  •  
  • #div2 {
  •  animation-name: anim2;
  •  -moz-animation-name: anim2;
  •  -o-animation-name: anim2;
  •  -webkit-animation-name: anim2;
  •  -moz-animation-iteration-count: infinite;
  •  -o-animation-iteration-count: infinite;
  •  -webkit-animation-iteration-count: infinite;
  • }
  •  
  • @keyframes anim2 {
  •  from {
  •   background-color: #A3E61D;
  •  }
  •  to {
  •   transform: scale(1.8, 1.8);
  •   -moz-transform: scale(1.8, 1.8);
  •   -o-transform: scale(1.8, 1.8);
  •   -webkit-transform: scale(1.8, 1.8);
  •   -ms-transform: scale(1.8, 1.8);
  •   background-color: #852E76;
  •  }
  • }
  •  
  • @-moz-keyframes anim2 {
  •  from {
  •   background-color: #A3E61D;
  •  }
  •  to {
  •   transform: scale(1.8, 1.8);
  •   -moz-transform: scale(1.8, 1.8);
  •   -o-transform: scale(1.8, 1.8);
  •   -webkit-transform: scale(1.8, 1.8);
  •   -ms-transform: scale(1.8, 1.8);
  •   background-color: #852E76;
  •  }
  • }
  •  
  • @-o-keyframes anim2 {
  •  from {
  •   background-color: #A3E61D;
  •  }
  •  to {
  •   transform: scale(1.8, 1.8);
  •   -moz-transform: scale(1.8, 1.8);
  •   -o-transform: scale(1.8, 1.8);
  •   -webkit-transform: scale(1.8, 1.8);
  •   -ms-transform: scale(1.8, 1.8);
  •   background-color: #852E76;
  •  }
  • }
  •  
  • @-webkit-keyframes anim2 {
  •  from {
  •   background-color: #A3E61D;
  •  }
  •  to {
  •   transform: scale(1.8, 1.8);
  •   -moz-transform: scale(1.8, 1.8);
  •   -o-transform: scale(1.8, 1.8);
  •   -webkit-transform: scale(1.8, 1.8);
  •   -ms-transform: scale(1.8, 1.8);
  •   background-color: #852E76;
  •  }
  • }
  •  
  • #div3 {
  •  animation-name: anim3;
  •  -moz-animation-name: anim3;
  •  -o-animation-name: anim3;
  •  -webkit-animation-name: anim3;
  • }
  •  
  • @keyframes anim3 {
  •  from {
  •   top: 300px;
  •   background-color: #3BA9DE;
  •  }
  •  to {
  •   top: 520px;
  •   left: 310px;
  •   background-color: #A3E61D;
  •  }
  • }
  •  
  • @-moz-keyframes anim3 {
  •  from {
  •   top: 300px;
  •   background-color: #3BA9DE;
  •  }
  •  to {
  •   top: 520px;
  •   left: 310px;
  •   background-color: #A3E61D;
  •  }
  • }
  •  
  • @-o-keyframes anim3 {
  •  from {
  •   top: 300px;
  •   background-color: #3BA9DE;
  •  }
  •  to {
  •   top: 520px;
  •   left: 310px;
  •   background-color: #A3E61D;
  •  }
  • }
  •  
  • @-webkit-keyframes anim3 {
  •  from {
  •   top: 300px;
  •   background-color: #3BA9DE;
  •  }
  •  to {
  •   top: 520px;
  •   left: 310px;
  •   background-color: #A3E61D;
  •  }
  • }
* {
 margin: 0;
 padding: 0;
}

.main {
 height: 600px;
 width: 900px;
 position: absolute;
 top: 50%;
 left: 50%;
 margin-top: -300px;
 margin-left: -450px;
}

.wrapper {
 width: 33.3%;
 height: 100%;
 float: left;
}

#div1, #div2, #div3 {
 height: 100px;
 width: 100px;
 float: left;
 position: relative;
 top: 50%;
 left: 50%;
 margin-top: -50px;
 margin-left: -50px;
 animation-duration: 3s;
 -moz-animation-duration: 3s;
 -o-animation-duration: 3s;
 -webkit-animation-duration: 3s;
}

#div1 {
 animation-name: anim1;
 -moz-animation-name: anim1;
 -o-animation-name: anim1;
 -webkit-animation-name: anim1;
 animation-iteration-count: 1;
 -moz-animation-iteration-count: 1;
 -o-animation-iteration-count: 1;
 -webkit-animation-iteration-count: 1;
}

@keyframes anim1 {
 from {
  background-color: #3BA9DE;
 }
 to {
  top: 80px;
  left: -10px;
  background-color: #A3E61D;
 }
}

@-moz-keyframes anim1 {
 from {
  background-color: #3BA9DE;
 }
 to {
  top: 80px;
  left: -10px;
  background-color: #A3E61D;
 }
}

@-o-keyframes anim1 {
 from {
  background-color: #3BA9DE;
 }
 to {
  top: 80px;
  left: -10px;
  background-color: #A3E61D;
 }
}

@-webkit-keyframes anim1 {
 from {
  background-color: #3BA9DE;
 }
 to {
  top: 80px;
  left: -10px;
  background-color: #A3E61D;
 }
}

#div2 {
 animation-name: anim2;
 -moz-animation-name: anim2;
 -o-animation-name: anim2;
 -webkit-animation-name: anim2;
 -moz-animation-iteration-count: infinite;
 -o-animation-iteration-count: infinite;
 -webkit-animation-iteration-count: infinite;
}

@keyframes anim2 {
 from {
  background-color: #A3E61D;
 }
 to {
  transform: scale(1.8, 1.8);
  -moz-transform: scale(1.8, 1.8);
  -o-transform: scale(1.8, 1.8);
  -webkit-transform: scale(1.8, 1.8);
  -ms-transform: scale(1.8, 1.8);
  background-color: #852E76;
 }
}

@-moz-keyframes anim2 {
 from {
  background-color: #A3E61D;
 }
 to {
  transform: scale(1.8, 1.8);
  -moz-transform: scale(1.8, 1.8);
  -o-transform: scale(1.8, 1.8);
  -webkit-transform: scale(1.8, 1.8);
  -ms-transform: scale(1.8, 1.8);
  background-color: #852E76;
 }
}

@-o-keyframes anim2 {
 from {
  background-color: #A3E61D;
 }
 to {
  transform: scale(1.8, 1.8);
  -moz-transform: scale(1.8, 1.8);
  -o-transform: scale(1.8, 1.8);
  -webkit-transform: scale(1.8, 1.8);
  -ms-transform: scale(1.8, 1.8);
  background-color: #852E76;
 }
}

@-webkit-keyframes anim2 {
 from {
  background-color: #A3E61D;
 }
 to {
  transform: scale(1.8, 1.8);
  -moz-transform: scale(1.8, 1.8);
  -o-transform: scale(1.8, 1.8);
  -webkit-transform: scale(1.8, 1.8);
  -ms-transform: scale(1.8, 1.8);
  background-color: #852E76;
 }
}

#div3 {
 animation-name: anim3;
 -moz-animation-name: anim3;
 -o-animation-name: anim3;
 -webkit-animation-name: anim3;
}

@keyframes anim3 {
 from {
  top: 300px;
  background-color: #3BA9DE;
 }
 to {
  top: 520px;
  left: 310px;
  background-color: #A3E61D;
 }
}

@-moz-keyframes anim3 {
 from {
  top: 300px;
  background-color: #3BA9DE;
 }
 to {
  top: 520px;
  left: 310px;
  background-color: #A3E61D;
 }
}

@-o-keyframes anim3 {
 from {
  top: 300px;
  background-color: #3BA9DE;
 }
 to {
  top: 520px;
  left: 310px;
  background-color: #A3E61D;
 }
}

@-webkit-keyframes anim3 {
 from {
  top: 300px;
  background-color: #3BA9DE;
 }
 to {
  top: 520px;
  left: 310px;
  background-color: #A3E61D;
 }
}


index.html
  • <!DOCTYPE html>
  • <html>
  • <head>
  •  <meta charset="utf-8" />
  •  <title>New Page</title>
  •  <link href="css/style.css" rel="stylesheet" />
  •  <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
  • </head>
  • <body>
  •  <div class="main">
  •   <div class="wrapper">
  •    <div id="div1"></div>
  •   </div>
  •   <div class="wrapper">
  •    <div id="div2"></div>
  •   </div>
  •   <div class="wrapper">
  •    <div id="div3"></div>
  •   </div>
  •  </div>
  • <script>
  •  /*JavaScript*/
  •  document.getElementById("div2").style.animationIterationCount="infinite";
  •  document.getElementById("div2").style.msAnimationIterationCount="infinite";
  •  /*jQuery*/
  •  $(document).ready(function() {
  •   $("#div3").css({ "animation-iteration-count": "2" });
  •   $("#div3").css({ "-moz-animation-iteration-count": "2" });
  •   $("#div3").css({ "-o-animation-iteration-count": "2" });
  •   $("#div3").css({ "-webkit-animation-iteration-count": "2" });
  •  });
  • </script>
  • </body>
  • </html>
  • <!DOCTYPE html>
  • <html>
  • <head>
  •  <meta charset="utf-8" />
  •  <title>New Page</title>
  •  <link href="css/style.css" rel="stylesheet" />
  •  <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
  • </head>
  • <body>
  •  <div class="main">
  •   <div class="wrapper">
  •    <div id="div1"></div>
  •   </div>
  •   <div class="wrapper">
  •    <div id="div2"></div>
  •   </div>
  •   <div class="wrapper">
  •    <div id="div3"></div>
  •   </div>
  •  </div>
  • <script>
  •  /*JavaScript*/
  •  document.getElementById("div2").style.animationIterationCount="infinite";
  •  document.getElementById("div2").style.msAnimationIterationCount="infinite";
  •  /*jQuery*/
  •  $(document).ready(function() {
  •   $("#div3").css({ "animation-iteration-count": "2" });
  •   $("#div3").css({ "-moz-animation-iteration-count": "2" });
  •   $("#div3").css({ "-o-animation-iteration-count": "2" });
  •   $("#div3").css({ "-webkit-animation-iteration-count": "2" });
  •  });
  • </script>
  • </body>
  • </html>