From the course: CSS: Animation
Unlock the full course today
Join today to access over 23,000 courses taught by industry experts.
Pause and play with animation-play-state - CSS Tutorial
From the course: CSS: Animation
Pause and play with animation-play-state
- [Instructor] So far, we've been creating animations that play automatically on page load. But there are definitely times where you might want to change when an animation starts or temporarily pause an animation while it's playing. The animation-play-state property can be very useful for both those things. For this example, we're using this spinning sub sticker image. It's a little silly, but it totally works for what we're demonstrating here. We're going to use the animation-play-state property to have this sub spin only when we're hovering over it. And be paused when we're not. We're using hover in this example, because it's an easy input event for CSS to access. But you might find that changing the animation-play-state on events like click or scroll with the help of JavaScript to be even more useful. I've already got the keyframes for the spinning animation here, and we just saw it in action a minute ago. But I can…
Contents
-
-
-
-
-
Infinitely looping animations3m 58s
-
(Locked)
Pause and play with animation-play-state3m 16s
-
(Locked)
Animating 3D transforms5m 24s
-
(Locked)
Chaining multiple keyframe animations4m 48s
-
(Locked)
Challenge: Adding a third animation to the chain33s
-
(Locked)
Solution: Adding a third animation to the chain2m 16s
-
-
-
-
-