/

HTML / CSS / JavaScript Tutorial

CSS Property: animation-delay

[this page | pdf | back links]

The CSS (CSS3) animation-delay property specifies the delay until the start of an animation.

 

Valid property values (other than inherit and initial) are:

 

Value

Description

time

Length of time (in CSS time units) to start of animation

 

Default Value:

0s

JavaScript syntax:

e.g. object.style.animationDelay="2s"

Inherited:

No

Animatable:

No

 

EXAMPLE:


HTML USED IN THIS EXAMPLE:
<!DOCTYPE html>
<html> <!-- Copyright (c) Nematrian Limited 2018 -->
<head>
<style>
div {width: 100px; height: 40px; position: relative; 
  background: yellow; animation: anim 2s infinite;}
div.x1 {animation-delay: 3s;}
@keyframes anim {from {left: 0px} to {left: 50px;} } 
</style>
</head>
<body>
1. Element set using in-file HTML style<br>
<div class="x1">&nbsp;</div><br><br>
2. Element set using JavaScript<br>
<div id="x2">&nbsp;</div>

<script>
document.getElementById("x2").style.animationDelay = "3s";
</script>

</body>
</html>

FUNCTION THAT MAY ASSIST IN TESTING WHETHER FEATURE IS SUPPORTED:
function isSupportedCSSPropertyAnimationDelay() {
  var x = document.createElement("DIV"); x.style.animationDelay = "3s"; return (window.getComputedStyle(x, null).animationDelay == "3s");
}


NAVIGATION LINKS
Contents | Prev | Next | CSS Properties


Desktop view | Switch to Mobile