Syntax:
transition-delay : <time> [, <time>]*
transition-delay is used to specify the time when an animation starts to execute, that is, how long it takes after the element attribute value is changed. Start executing the transition effect, its value: <time> is a numerical value, the unit is s (seconds) or ms (milliseconds), its use is very similar to transition-duration, and can also be applied to all elements, including: before and: after Pseudo elements. The default size is "0", which means the transformation is performed immediately without delay.
Sometimes we not only change the properties of one css effect, but want to change the transition effects of two or more css properties, then we only need to string several transition statements together with commas ("," ) separated, and then each can have its own different duration and time rate transformation method. But something worth noting: The values of transition-delay and transition-duration are both times, so to distinguish their positions in the sequence, browsers generally decide according to the order. The first value that can be parsed as time is The second transition-duration is transition-delay. For example:
a { -moz-transition: background 0.5s ease-in,color 0.3s ease-out; -webkit-transition: background 0.5s ease-in,color 0.3s ease-out; -o-transition: background 0.5s ease-in,color 0.3s ease-out; transition: background 0.5s ease-in,color 0.3s ease-out; }
If you want to perform all transition effect attributes on the element, then we can also use the all attribute value to operate. At this time, they share the same duration and rate transformation method. , such as:
a { -moz-transition: all 0.5s ease-in; -webkit-transition: all 0.5s ease-in; -o-transition: all 0.5s ease-in; transition: all 0.5s ease-in; }
Based on the above, we can give transition a shorthand: transition: <property> <duration> <animation type> <delay> as shown below:
Corresponding example code:
p { -webkit-transition: all .5s ease-in-out 1s; -o-transition: all .5s ease-in-out 1s; -moz-transition: all .5s ease-in-out 1s; transition: all .5s ease-in-out 1s;}
Code example:
Example one:
<!DOCTYPE html> <html> <head> <meta charset=" utf-8"> <meta name="author" content="http://www.php.cn/" /> <title>php中文网</title> <style type="text/css"> #thediv{ width:100px; height:100px; background:blue; transition-property:width,height; -moz-transition-property:width,height; -webkit-transition-property:width,height; -o-transition-property:width,height; transition-duration:2s; -moz-transition-duration:2s; -webkit-transition-duration:2s; -o-transition-duration:2s; transition-delay:2s; -moz-transition-delay:2s; -webkit-transition-delay:2s; -o-transition-delay:2s; } #thediv:hover{ width:500px; height:200px; } </style> </head> <body> <div id="thediv"></div> </body> </html>
In the above code, hovering the mouse over the div requires a delay of two seconds before executing the animation effect.
Example 2:
<!DOCTYPE html> <html> <head> <meta charset=" utf-8"> <meta name="author" content="http://www.php.cn/" /> <title>php中文网</title> <style> #thediv{ width:100px; height:100px; background:blue; transition-property:width,height; -moz-transition-property:width,height; -webkit-transition-property:width,height; -o-transition-property:width,height; transition-duration:2s,6s; -moz-transition-duration:2s,6s; -webkit-transition-duration:2s,6s; -o-transition-duration:2s,6s; transition-delay:2s,6s; -moz-transition-delay:2s,6s; -webkit-transition-delay:2s,6s; -o-transition-delay:2s,6s; } #thediv:hover{ width:500px; height:200px; } </style> </head> <body> <div id="thediv"></div> </body> </html>
In the above code, when the mouse is hovering over the div, it will delay 2 seconds and 6 seconds respectively before starting to point to the width and height. Animated transition effects.
Next Section