Home >Web Front-end >CSS Tutorial >Sets how many times the animation should run using CSS

Sets how many times the animation should run using CSS

王林
王林forward
2023-08-28 10:53:171272browse

设置动画应使用 CSS 运行多少次

Use the animation-iteration-count property to set the number of times the animation should run using CSS.

The following example sets the animation count 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>

The above is the detailed content of Sets how many times the animation should run using CSS. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:tutorialspoint.com. If there is any infringement, please contact admin@php.cn delete