Open In App

CSS transition-duration Property

The transition-duration property in CSS is used to specify the length of time (in seconds or milliseconds) to complete the transition effect. 

Syntax:



transition-duration: time|initial|inherit;

Property Values:

Syntax:



transition-duration: time;

Example: 




<!DOCTYPE html>
<html>
<head>
    <title>
        CSS transition-duration Property
    </title>
 
    <style>
        div {
            width: 100px;
            height: 70px;
            background: green;
            transition-property: width;
            transition-duration: 5s;
 
            /* For Firefox browser */
            -webkit-transition-property: width;
            -webkit-transition-duration: 5s;
            transition-delay: .2s;
            display: inline-block;
        }
 
        div:hover {
            width: 300px;
        }
    </style>
</head>
 
<body style="text-align:center;">
 
    <h1>GeeksforGeeks</h1>
 
    <h2>Transition Property</h2>
 
    <div>
        <p>transition-duration: 5s</p>
    </div>
</body>
</html>

Output:

 

Example: In this example, we are using transition-duration: initial property.




<!DOCTYPE html>
<html>
<head>
    <title>
        CSS transition-duration Property
    </title>
 
    <style>
        div {
            width: 100px;
            height: 80px;
            background: green;
            transition-property: width;
            transition-duration: initial;
 
            /* For Firefox browser */
            -webkit-transition-property: width;
            -webkit-transition-duration: initial;
            transition-delay: .2s;
            display: inline-block;
        }
 
        div:hover {
            width: 300px;
        }
    </style>
</head>
 
<body style="text-align:center;">
 
    <h1>GeeksforGeeks</h1>
 
    <h2>Transition Property</h2>
 
    <div>
        <p>transition-duration: initial;</p>
    </div>
</body>
</html>

Output:

 

Example 3: In this example, we are using transition-duration: inherit property.




<!DOCTYPE html>
<html>
<head>
    <title>
        CSS transition-duration Property
    </title>
 
    <style>
        div {
            width: 100px;
            height: 270px;
            background: green;
            transition-property: width;
            transition-duration: inherit;
            transition-timing-function: ease-in;
            transition-delay: .2s;
            display: inline-block;
        }
 
        div:hover {
            width: 500px;
        }
    </style>
</head>
 
<body style="text-align:center;">
 
    <h1>GeeksforGeeks</h1>
 
    <h2>Transition Property</h2>
 
    <div>
        <p>transition-duration: inherit</p>
    </div>
</body>
</html>

Output: 

 

Supported Browsers: The browser supported by transition-duration property are listed below:


Article Tags :