animation-play-state
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-play-state 㯠CSS ã®ããããã£ã§ãã¢ãã¡ã¼ã·ã§ã³ãå®è¡ä¸ã忢ä¸ããè¨å®ãã¾ãã
試ãã¦ã¿ã¾ããã
animation-play-state: paused;
animation-play-state: running;
<section class="flex-column" id="default-example">
<div class="animating" id="example-element"></div>
</section>
#example-element {
background-color: #1766aa;
color: white;
margin: auto;
margin-left: 0;
border: 5px solid #333;
width: 150px;
height: 150px;
border-radius: 50%;
}
.animating {
animation-name: slide;
animation-duration: 3s;
animation-timing-function: ease-in;
animation-iteration-count: infinite;
animation-direction: alternate;
}
@keyframes slide {
from {
background-color: orange;
color: black;
margin-left: 0;
}
to {
background-color: orange;
color: black;
margin-left: 80%;
}
}
忢ããã¢ãã¡ã¼ã·ã§ã³ãåéããã¨ãã¢ãã¡ã¼ã·ã§ã³ã®æµãã®æåããã§ã¯ãªãã忢ããä½ç½®ããã¢ãã¡ã¼ã·ã§ã³ãå§ã¾ãã¾ãã
æ§æ
/* åä¸ã®ã¢ãã¡ã¼ã·ã§ã³ */
animation-play-state: running;
animation-play-state: paused;
/* è¤æ°ã®ã¢ãã¡ã¼ã·ã§ã³ */
animation-play-state: paused, running, running;
/* ã°ãã¼ãã«å¤ */
animation-play-state: inherit;
animation-play-state: initial;
animation-play-state: revert;
animation-play-state: revert-layer;
animation-play-state: unset;
å¤
running-
ã¢ãã¡ã¼ã·ã§ã³ãç¾å¨å®è¡ä¸ã§ãã
paused-
ã¢ãã¡ã¼ã·ã§ã³ãç¾å¨åæ¢ä¸ã§ãã
ã¡ã¢:
animation-* ããããã£ã«ã«ã³ãåºåãã§è¤æ°ã®å¤ãæå®ããå ´åã animation-name ã«ç¾ããé ã«ã¢ãã¡ã¼ã·ã§ã³ã«é©ç¨ããã¾ããã¢ãã¡ã¼ã·ã§ã³ã®æ°ã¨ animation-* ããããã£ã®å¤ãä¸è´ããªãå ´åã¯ãè¤æ°ã®ã¢ãã¡ã¼ã·ã§ã³ããããã£å¤ã®è¨å® ãåç
§ãã¦ãã ããã
å ¬å¼å®ç¾©
| åæå¤ | running |
|---|---|
| é©ç¨å¯¾è±¡ | ãã¹ã¦ã®è¦ç´ ã::before / ::after æ¬ä¼¼è¦ç´ |
| ç¶æ¿ | ãªã |
| è¨ç®å¤ | æå®éã |
| ã¢ãã¡ã¼ã·ã§ã³ã®ç¨®é¡ | ã¢ãã¡ã¼ã·ã§ã³ä¸å¯ |
形弿æ³
animation-play-state =
<single-animation-play-state>#
<single-animation-play-state> =
running |
paused
ä¾
>ã¢ãã¡ã¼ã·ã§ã³ã®åæ¢
ãã®ã¢ãã¡ã¼ã·ã§ã³ã¯åæ¢ãã¦ãã¾ããããã¤ã³ã¿ã¼ãå½ã¦ãã¨å®è¡ããã¾ãã
HTML
<div class="box"></div>
CSS
.box {
background-color: rebeccapurple;
border-radius: 10px;
width: 100px;
height: 100px;
animation-name: rotate;
animation-duration: 0.7s;
animation-iteration-count: infinite;
animation-play-state: paused;
}
.box:hover {
animation-play-state: running;
}
@keyframes rotate {
0% {
transform: rotate(0);
}
100% {
transform: rotate(360deg);
}
}
çµæ
ç©å½¢ã«ãã¤ã³ã¿ã¼ãå½ã¦ãã¨ã¢ãã¡ã¼ã·ã§ã³ãå§ã¾ãã¾ãã
ä¾ã«ã¤ãã¦ã¯ CSS ã¢ãã¡ã¼ã·ã§ã³ãåç §ãã¦ãã ããã
仿§æ¸
| Specification |
|---|
| CSS Animations Level 1 > # animation-play-state > |
ãã©ã¦ã¶ã¼ã®äºææ§
é¢é£æ å ±
- CSS ã¢ãã¡ã¼ã·ã§ã³ã®ä½¿ç¨
- JavaScript
AnimationEventAPI - ãã®ä»ã®ã¢ãã¡ã¼ã·ã§ã³é¢é£ããããã£:
animation,animation-composition,animation-delay,animation-direction,animation-duration,animation-fill-mode,animation-iteration-count,animation-name,animation-timeline,animation-timing-function