CSS3 Transitions
With CSS3, we can add an effect when changing from one style to another, without using Flash animations or JavaScripts.
A transition is such a property of CSS3, which is used to animate the object, without using flash or any other animation application. With this feature of CSS3 You can change the shape and size of your object with animated effects.
How does it work?
CSS3 transitions are effects that let an element gradually change from one style to another.
Transition Properties
Property Description
transition Shorthand property for setting all transition properties
transition-duration Defines the length of time that a transition takes.Default 0
transition-delay Specifies when the transition effect will start
CSS3 transition Property:
The transition property is a shorthand property for the four transition properties: transition-property, transition-duration, transition-timing-function, and transition-delay.
Syntax
transition: property duration timing-function delay;
Example:
<!DOCTYPE HTML>
<html lang="en-US">
<head>
<meta charset=utf-8>
<title>CSS3 Examples</title>
<style type="text/css">
div
{
width:100px;
height:100px;
background:blue;
transition:width 2s;
}
div:hover
{
width:300px;
}
</style>
</head>
<body>
<div></div>
<p>Hover over the div element above, to see the transition effect.</p>
</body>
</html>
CSS3 transition-duration Property
It specifies how many seconds (s) or milliseconds (ms) a transition effect takes to complete.
Syntax
transition-duration: time;
Value Description
time Specifies how many seconds or milliseconds a transition effect takes to complete.
Example:
<!DOCTYPE HTML>
<html lang="en-US">
<head>
<meta charset=utf-8>
<title>CSS3 Examples</title>
<style type="text/css">
div
{
width:100px;
height:100px;
background:blue;
transition:width 2s;
transition-duration:5s;
}
div:hover
{
width:300px;
}
</style>
</head>
<body>
<div></div>
<p>Hover over the div element above, to see the transition effect.</p>
</body>
</html>
CSS3 transition-delay Property
It specifies when the transition effect will start. The transition-delay value is defined in seconds (s) or milliseconds (ms).
Syntax
transition-delay: time;
Value Description
time Specifies the number of seconds or milliseconds to wait before the transition effect will start.
Example:
<!DOCTYPE HTML>
<html lang="en-US">
<head>
<meta charset=utf-8>
<title>CSS3 Examples</title>
<style type="text/css">
div
{
width:100px;
height:100px;
background:blue;
transition:width 2s;
transition-duration:5s;
transition-delay:2s;
}
div:hover
{
width:300px;
}
</style>
</head>
<body>
<div></div>
<p>Hover over the div element above, to see the transition effect.</p>
<p><b>Note:</b> The transition effect will wait 2 seconds before starting.</p>
</body>
</html>
With CSS3, we can add an effect when changing from one style to another, without using Flash animations or JavaScripts.
A transition is such a property of CSS3, which is used to animate the object, without using flash or any other animation application. With this feature of CSS3 You can change the shape and size of your object with animated effects.
How does it work?
CSS3 transitions are effects that let an element gradually change from one style to another.
Transition Properties
Property Description
transition Shorthand property for setting all transition properties
transition-duration Defines the length of time that a transition takes.Default 0
transition-delay Specifies when the transition effect will start
CSS3 transition Property:
The transition property is a shorthand property for the four transition properties: transition-property, transition-duration, transition-timing-function, and transition-delay.
Syntax
transition: property duration timing-function delay;
Example:
<!DOCTYPE HTML>
<html lang="en-US">
<head>
<meta charset=utf-8>
<title>CSS3 Examples</title>
<style type="text/css">
div
{
width:100px;
height:100px;
background:blue;
transition:width 2s;
}
div:hover
{
width:300px;
}
</style>
</head>
<body>
<div></div>
<p>Hover over the div element above, to see the transition effect.</p>
</body>
</html>
CSS3 transition-duration Property
It specifies how many seconds (s) or milliseconds (ms) a transition effect takes to complete.
Syntax
transition-duration: time;
Value Description
time Specifies how many seconds or milliseconds a transition effect takes to complete.
Example:
<!DOCTYPE HTML>
<html lang="en-US">
<head>
<meta charset=utf-8>
<title>CSS3 Examples</title>
<style type="text/css">
div
{
width:100px;
height:100px;
background:blue;
transition:width 2s;
transition-duration:5s;
}
div:hover
{
width:300px;
}
</style>
</head>
<body>
<div></div>
<p>Hover over the div element above, to see the transition effect.</p>
</body>
</html>
CSS3 transition-delay Property
It specifies when the transition effect will start. The transition-delay value is defined in seconds (s) or milliseconds (ms).
Syntax
transition-delay: time;
Value Description
time Specifies the number of seconds or milliseconds to wait before the transition effect will start.
Example:
<!DOCTYPE HTML>
<html lang="en-US">
<head>
<meta charset=utf-8>
<title>CSS3 Examples</title>
<style type="text/css">
div
{
width:100px;
height:100px;
background:blue;
transition:width 2s;
transition-duration:5s;
transition-delay:2s;
}
div:hover
{
width:300px;
}
</style>
</head>
<body>
<div></div>
<p>Hover over the div element above, to see the transition effect.</p>
<p><b>Note:</b> The transition effect will wait 2 seconds before starting.</p>
</body>
</html>