CSS animation-name

The CSS animation-name property is used to define the name for an animation or @keyframes. For example:

HTML with CSS Code
<!DOCTYPE html>
<html>
<head>
   <style>
      div#mydiv {width: 50px; height: 50px; border-radius: 50%;
         background-color: maroon; position: relative;
         animation-name: fresherearth; animation-duration: 2s; animation-iteration-count: infinite;}
      @keyframes fresherearth {
         from {background-color: crimson; top: 0px; left: 0px;}
         to {background-color: darkblue; top: 220px; left: 220px;}
      }
   </style>
</head>
<body>

   <div id="mydiv"></div>
   
</body>
</html>
Output

Note - The animation-duration is used to define time to complete one iteration or cycle of an animation.

Note - The animation-iteration-count is used to define the total number of iterations or cycles for an animation to play.

Note - The @keyframes is used to define the change in styles for multiple times in one cycle of selected animation.

CSS animation-name Syntax

The syntax of animation-name property in CSS, is:

animation-name: x;

The value of x should be any of the following:

CSS Online Test


« Previous Tutorial Next Tutorial »