CSS animation-play-state

The CSS animation-play-state property is used to pause or play an animation. For example:

HTML with CSS Code
<!DOCTYPE html>
      #mydiv {width: 50px; height: 50px; border-radius: 50%;
         background-color: maroon; position: relative;
         animation-name: codescracker; animation-duration: 2s; animation-iteration-count: infinite;}
      @keyframes codescracker {
         from {top: 0px; left: 0px;}
         to {top: 0px; left: 220px;}
      #mydiv:hover{animation-play-state: paused;}

   <div id="mydiv"></div>

When you hover the mouse cursor on the moving circle, then animation get paused.

Note - The animation-name is used to define a name for an animation.

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-play-state Syntax

The syntax of animation-play-state property in CSS, is:

animation-play-state: x;

The value of x should be any of the following:

CSS Online Test

« Previous Tutorial Next Tutorial »

Liked this post? Share it!