CSS Property: animation-iteration-count
[this page | pdf | back links]
The CSS (CSS3) animation-iteration-count property specifies
the number of times an animation should play.
Valid property values
(other than inherit
and initial) are:
Value
|
Description
|
number
|
(integer). Number of
times an animation should be played
|
infinite
|
Indicates animation
should be played an infinite number of times
|
Default Value:
|
1
|
JavaScript syntax:
|
e.g. object.style.animationIterationCount = "infinite";
|
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;}
div.x1 {animation-iteration-count: 2;}
@keyframes anim {from {left: 0px} to {left: 50px;} }
</style>
</head>
<body>
1. Element set using in-file HTML style<br>
<div class="x1"> </div><br><br>
2. Element set using JavaScript<br>
<div id="x2"> </div>
<script>
document.getElementById("x2").style.animationIterationCount = "infinite";
</script>
</body>
</html>
|
FUNCTION THAT MAY ASSIST IN TESTING WHETHER FEATURE IS SUPPORTED:
function isSupportedCSSPropertyAnimationIterationCount() {
var x = document.createElement("DIV"); x.style.animationIterationCount = "infinite"; return (window.getComputedStyle(x, null).animationIterationCount == "infinite");
} |
NAVIGATION LINKS
Contents | Prev | Next | CSS Properties