animation-iteration-count
Baseline
Widely available
This feature is well established and works across many devices and browser versions. Itâs been available across browsers since 2015ë 9ì.
animation-iteration-count CSS ìì±ì ì ëë©ì´ì
ìíì¤ê° ëë기 ì ì ì¬ìëë íì를 ì¤ì í©ëë¤.
ìëí´ ë³´ê¸°
animation-iteration-count: 0;
animation-iteration-count: 2;
animation-iteration-count: 1.5;
<section class="flex-column" id="default-example">
<div>Animation <span id="playstatus"></span></div>
<div id="example-element">Select a count to start!</div>
</section>
#example-element {
align-items: center;
background-color: #1766aa;
border-radius: 50%;
border: 5px solid #333;
color: white;
display: flex;
flex-direction: column;
height: 150px;
justify-content: center;
margin: auto;
margin-left: 0;
width: 150px;
}
#playstatus {
font-weight: bold;
}
.animating {
animation-name: slide;
animation-duration: 3s;
animation-timing-function: ease-in;
}
@keyframes slide {
from {
background-color: orange;
color: black;
margin-left: 0;
}
to {
background-color: orange;
color: black;
margin-left: 80%;
}
}
"use strict";
window.addEventListener("load", () => {
const el = document.getElementById("example-element");
const status = document.getElementById("playstatus");
function update() {
status.textContent = "delaying";
el.className = "";
window.requestAnimationFrame(() => {
window.requestAnimationFrame(() => {
el.className = "animating";
});
});
}
el.addEventListener("animationstart", () => {
status.textContent = "playing";
});
el.addEventListener("animationend", () => {
status.textContent = "finished";
});
const observer = new MutationObserver(() => {
update();
});
observer.observe(el, {
attributes: true,
attributeFilter: ["style"],
});
update();
});
모ë ì ëë©ì´ì
ìì±ì í ë²ì ì¤ì íë¤ë©´ ë¨ì¶ ìì± animation를 ì¬ì©íë©´ í¸ë¦¬í©ëë¤.
구문
/* Keyword value */
animation-iteration-count: infinite;
/* <number> values */
animation-iteration-count: 3;
animation-iteration-count: 2.4;
/* Multiple values */
animation-iteration-count: 2, 0, infinite;
/* Global values */
animation-iteration-count: inherit;
animation-iteration-count: initial;
animation-iteration-count: revert;
animation-iteration-count: revert-layer;
animation-iteration-count: unset;
animation-iteration-count ìì±ì ê°ì¼ë¡ íë í¹ì ì¬ë¬ ê°ì ì¼íë¡ êµ¬ë¶í ê°ì ì§ì í©ëë¤.
ê°
infinite-
ì ëë©ì´ì ì´ ê³ì ë°ë³µë©ëë¤.
<number>-
ì ëë©ì´ì ì´ ë°ë³µëë íìì ëë¤. 기본ê°ì 1ë¡ ì§ì ëì´ ììµëë¤. ì ëë©ì´ì 주기ì ì¼ë¶ë¶ë§ ì¬ìí기 ìí´ ì ìê° ìë ê°ì ì§ì í ì ììµëë¤. ì를 ë¤ì´,
0.5ë ì ëë©ì´ì 주기ì ì ë°ë§ ì¬ìí©ëë¤. ìì ê°ì ì í¨íì§ ììµëë¤.
ì°¸ê³ :
animation-* ìì±ì ì¬ë¬ ê°ì ì¼íë¡ êµ¬ë¶ë ê°ì ì§ì íë©´ animation-name ìì±ì ì§ì ë ì ëë©ì´ì
ì í ë¹ëë ê°ì ìì ë°ë¼ ë¤ë¥¸ ë°©ìì¼ë¡ ì§ì ë©ëë¤. ìì¸í ë´ì©ì ì¬ë¬ ì ëë©ì´ì
ìì± ê° ì¤ì ì 참조íììì¤.
ì°¸ê³ :
CSS ì¤í¬ë¡¤ ê¸°ë° ì ëë©ì´ì
ì ë§ë¤ ë, animation-iteration-count ìì±ì ì§ì íë©´ íìë¼ì¸ì´ ì§íëë ëì ì ëë©ì´ì
ì´ í´ë¹ íìë§í¼ ë°ë³µë©ëë¤. animation-iteration-count ìì±ì ì§ì íì§ ìì¼ë©´, ì ëë©ì´ì
ì í ë²ë§ ì¤íë©ëë¤. infiniteë ì¤í¬ë¡¤ ê¸°ë° ì ëë©ì´ì
ìì ì í¨í ê°ì´ì§ë§ ì ëë©ì´ì
ì´ ìëíì§ ìê² ë©ëë¤.
íì ì ì
| ì´ê¸°ê° | 1 |
|---|---|
| ì ì©ëì | all elements, ::before and ::after pseudo-elements |
| ìì | no |
| ê³ì° ê° | as specified |
| Animation type | Not animatable |
íì 구문
animation-iteration-count =
<single-animation-iteration-count>#
<single-animation-iteration-count> =
infinite |
<number [0,â]>
ìì
>ë°ë³µ íì ì¤ì í기
ì´ ì ëë©ì´ì ì 10ë² ì¤íë©ëë¤.
HTML
<div class="box"></div>
CSS
.box {
background-color: rebeccapurple;
border-radius: 10px;
width: 100px;
height: 100px;
}
.box:hover {
animation-name: rotate;
animation-duration: 0.7s;
animation-iteration-count: 10;
}
@keyframes rotate {
0% {
transform: rotate(0);
}
100% {
transform: rotate(360deg);
}
}
ê²°ê³¼
ì ëë©ì´ì ì íì¸íë ¤ë©´ ì§ì¬ê°íì ë§ì°ì¤ë¥¼ ê°ì ¸ê°ì¸ì.
ë¤ë¥¸ ìì ë¤ì CSS animationsì 참조íì¸ì.
ëª ì¸ì
| Specification |
|---|
| CSS Animations Level 1 > # animation-iteration-count > |
ë¸ë¼ì°ì í¸íì±
ê°ì´ 보기
- CSS ì ëë©ì´ì ì¬ì©í기
- JavaScript
AnimationEventAPI - ì ëë©ì´ì
ê³¼ ê´ë ¨ë ë¤ë¥¸ CSS ìì±:
animation,animation-composition,animation-delay,animation-direction,animation-duration,animation-fill-mode,animation-name,animation-play-state,animation-timeline,animation-timing-function