InfoHeap
Tech
Navigation
  • Home
  • Tutorials
    • CSS tutorials & examples
    • CSS properties
    • Javascript cookbook
    • Linux/Unix Command Line
    • Mac
    • PHP
      • PHP functions online
      • PHP regex
    • WordPress
  • Online Tools
    • Text utilities
    • Online Lint Tools
search

CSS animation

  • animation overview
  • animation-name
  • animation-duration
  • animation-timing-function
  • animation-delay
  • animation-iteration-count
  • animation-direction
  • animation-fill-mode
  • animation-play-state
  • animation shorthand
 
  • Home
  • > Tutorials
  • > CSS
  • > CSS properties
  • > CSS Animation

CSS animation-play-state

on Mar 24, 2016

CSS animation-play-state property defines whether the animation is running or paused. When a paused animation is resumed, it restarts from the current value instead of beginning of the animation.

In case animation-name has multiple values, animation-play-state can also have multiple values.

CSS property animation-play-state

CSS version: CSS 3
Value: [running | paused] [, ...]*
Initial: running
Applies to: all elements, ::before and ::after pseudo-elements
Inherited: no

Example – animation-play-state

<style>
@keyframes left-to-right {
  0% {left:0;}
  100% {left:200px;}
}
.box {
  position:fixed; background-color:lightgreen;
  animation-name: left-to-right;
  animation-duration: 4s;
  animation-iteration-count:infinite;
  animation-play-state: running;
}
</style>

<div class=box>Object</div>
<br/><br/><button onclick="toggleState()">toggle running/paused</button>
<script>
function toggleState() {
  var el = document.querySelector(".box");
  if (window.getComputedStyle(el).animationPlayState == 'running') {
    el.style.animationPlayState = 'paused';
  } else {
    el.style.animationPlayState = 'running';
  }
}
</script>
refresh done
try it online

Specification

  • W3C CSS 3 animation-play-state specification

Suggested posts:

  1. CSS – align div in center vertically
  2. CSS animation-duration
  3. CSS selector specificity
  4. CSS animation-iteration-count
  5. CSS animation-timing-function
  6. CSS animation-name
  7. CSS animation-direction
  8. CSS animation-delay
Share this article: share on facebook share on linkedin tweet this submit to reddit
Posted in Tutorials | Tagged CSS, CSS Animation, CSS properties, Tutorials
  • Browse content
  • Article Topics
  • Article archives
  • Contact Us
Popular Topics: Android Development | AngularJS | Apache | AWS and EC2 | Bash shell scripting | Chrome developer tools | Company results | CSS | CSS cookbook | CSS properties | CSS Pseudo Classes | CSS selectors | CSS3 | CSS3 flexbox | Devops | Git | HTML | HTML5 | Java | Javascript | Javascript cookbook | Javascript DOM | jQuery | Kubernetes | Linux | Linux/Unix Command Line | Mac | Mac Command Line | Mysql | Networking | Node.js | Online Tools | PHP | PHP cookbook | PHP Regex | Python | Python array | Python cookbook | SEO | Site Performance | SSH | Ubuntu Linux | Web Development | Webmaster | Wordpress | Wordpress customization | Wordpress How To | Wordpress Mysql Queries | InfoHeap Money

Copyright © 2025 InfoHeap.

Powered by WordPress