CSS | animation-duration Property

The animation-duration property in CSS is used to define how long an animation should take to complete one cycle. That is it is used to specify the time duration for which animation will be played.

Syntax:

animation-duration: time|initial|inherit;

Property Value:



  • time: This value is used to specify the length of time for which an animation will complete one cycle. This can be specified in either in seconds or in milliseconds. The default value is 0, which means that no animation will occur.
  • initial: This value is used to set the property to its default value.
  • inherit: This value is used to inherits the property from its parent element.

Example: HTML program to illustrate the animation-duration property in CSS.

filter_none

edit
close

play_arrow

link
brightness_4
code

<!DOCTYPR html>
<html>
  
<head>
    <title>
        CSS | animation-duration Property
    </title>
    <style>
        #gfg1 {
            animation-name: text;
            animation-duration: 5s;
            animation-iteration-count: infinite;
        }
          
        #geek1 {
            font-size: 40px;
            text-align: center;
            font-weight: bold;
            color: #090;
            padding-bottom: 5px;
        }
          
        #geek2 {
            font-size: 17px;
            font-weight: bold;
            text-align: center;
        }
          
        @keyframes text {
            from {
                margin-top: 400px;
            }
            to {
                margin-top: 0px;
            }
        }
    </style>
</head>
  
<body>
    <!-- The below div is animated for a duration of 5s 
       and will be played an infinite number of times -->
    <div id="gfg1">
        <div id="geek1">
            GeeksforGeeks
        </div>
        <div id="geek2">
            A computer science portal for geeks
        </div>
    </div>
</body>
  
</html>                                    

chevron_right


Supported Browser: The browser supported by animation-duration property are listed below:

  • Google Chrome 43.0
  • Internet Explorer 10.0
  • Firefox 16.0
  • Opera 30.0
  • Safari 9.0


My Personal Notes arrow_drop_up

Check out this Author's contributed articles.

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.




Article Tags :
Practice Tags :


Be the First to upvote.


Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.