Set how many times an Animation should run with CSS

CSSWeb DevelopmentFront End Technology

Use the animation-iteration-count property to set how many times the animation should run with CSS.

The following example sets the count of animation to 2:

Example

Live Demo

<!DOCTYPE html>
<html>
   <head>
      <style>
         div {
            width: 150px;
            height: 200px;
            background-color: yellow;
            animation-name: myanim;
            animation-duration: 2s;
            animation-iteration-count: 2;
         }
         @keyframes myanim {
         from {
            background-color: green;
         }
         to {
               background-color: blue;
            }
         }
      </style>
   </head>

   <body>
      <div> </div>
   </body>
</html>
raja
Published on 16-May-2018 16:36:26
Advertisements