English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

CSS Reference Manual

CSS @rules

Complete List of CSS Properties

CSS3 animation-Usage and examples of delay attribute

 CSS animation-The delay attribute defines when the animation starts playing (for example: the value of2s, indicating that the animation will start playing after the application2starts playing after 0 seconds. The value of this property can be specified in seconds (s) or milliseconds (ms).

The following table summarizes the usage context and version history of this property.

Default value:0s
Applies to:All elements ::before and ::after 伪元素
Pseudo-elementInheritance:
NoAnimatable:No See also.
Animation Attribute CSS3Version:
new feature    JavaScript Syntax:    object2object.style.animationDelay="

animation-s"

Syntax of delay usage

animation-The syntax of this attribute is as follows:

delay: time | initial | inherit-The following example demonstrates how to use animation

Example
    .box { 5height:
    width: 5height:
    0px;
    background: red;
    /* s; */
    -webkit-animation-position: relative;
    -webkit-animation-name: moveit; 4delay:
    -webkit-animation-duration: 2delay:
    
    animation-position: relative;
    animation-name: moveit; 4delay:
    animation-duration: 2delay:
0%;}
 
/* s; */
Chrome, Safari, Opera-webkit-@
    @keyframes moveit {
    from {left: 0;} 5to {left:
0%;}
 
keyframes moveit {
    @keyframes moveit {
    from {left: 0;} 5to {left:
0%;}
}/Test to see‹

Note:-2A negative value for the animation delay causes the animation to start immediately, but it seems to start in the middle of its animation cycle, for example2starts executing after a certain number of seconds.

Attribute Value

The following table describes the values of this attribute.

ValueDescription
timeDefine the number of seconds or milliseconds to wait before the animation starts. The default value is 0s.
initialSet this attribute to its default value.
inheritIf specified, the associated element adopts its parent element's animation-The calculated value of the delay attribute.

Browser Compatibility

animation-Browser Compatibility of delay Attribute, all mainstream browsers support this attribute.

  • Firefox 5+ -moz-,15 +

  • Google Chrome 4+ -webkit-

  • Internet Explorer 10+

  • Apple Safari 4+ -webkit-

  • Opera 12+ -o-, 15+ -webkit-

Further Reading

Please refer to the following tutorials:CSS3Animation.

Related Attributes and Rules:animation,animation-name,animation-duration,animation-timing-function,animation-iteration-count,animation-direction,animation-fill-mode,animation-play-state,@keyframes.