CSS Animation Play State
Submitted by alpha_luna on Friday, July 15, 2016 - 14:30.
Language
CSS animation-play-state
In this tutorial we are going to learn about animation-play-state. So, what is animation-play-state? The animation-play-state property specifies whether the animation is paused or running. Syntax of this property:animation-play-state: paused | running | initial | inherit ;
Property Values
- paused - specifies that the animation is paused.
- running - specifies that the animation is running. The default value is running.
- initial - specifies that the value of the property should be set to the default value.
- inherit - specifies that the value of the property should be inherited from the parent element.
CSS Style
- <style type="text/css">
- div.animate {
- width:50px;
- height:50px;
- color:white;
- padding:2px;
- background:blue;
- position:relative;
- animation:boxmove 5s infinite;
- /* Firefox */
- -moz-animation:boxmove 5s infinite;
- /* Safari and Google Chrome */
- -webkit-animation:boxmove 5s infinite;
- }
- #test1 {
- animation-play-state:running;
- /* Firefox */
- -moz-animation-play-state:running;
- /* Safari and Google Chrome */
- -webkit-animation-play-state:running;
- }
- #test2 {
- animation-play-state:paused;
- /* Firefox */
- -moz-animation-play-state:paused;
- /* Safari and Google Chrome */
- -webkit-animation-play-state:paused;
- }
- @keyframes boxmove
- {
- from {left:0px;}
- to {left:210px;}
- }
- @-moz-keyframes boxmove /* Firefox */
- {
- from {left:0px;}
- to {left:210px;}
- }
- @-webkit-keyframes boxmove /* Safari and Google Chrome */
- {
- from {left:0px;}
- to {left:210px;}
- }
- </style>
The Complete Source Code
- <!DOCTYPE html>
- <html>
- <head>
- <style type="text/css">
- div.animate {
- width:50px;
- height:50px;
- color:white;
- padding:2px;
- background:blue;
- position:relative;
- animation:boxmove 5s infinite;
- /* Firefox */
- -moz-animation:boxmove 5s infinite;
- /* Safari and Google Chrome */
- -webkit-animation:boxmove 5s infinite;
- }
- #test1 {
- animation-play-state:running;
- /* Firefox */
- -moz-animation-play-state:running;
- /* Safari and Google Chrome */
- -webkit-animation-play-state:running;
- }
- #test2 {
- animation-play-state:paused;
- /* Firefox */
- -moz-animation-play-state:paused;
- /* Safari and Google Chrome */
- -webkit-animation-play-state:paused;
- }
- @keyframes boxmove
- {
- from {left:0px;}
- to {left:210px;}
- }
- @-moz-keyframes boxmove /* Firefox */
- {
- from {left:0px;}
- to {left:210px;}
- }
- @-webkit-keyframes boxmove /* Safari and Google Chrome */
- {
- from {left:0px;}
- to {left:210px;}
- }
- </style>
- </head>
- <body>
- <br />
- </body>
- </html>
Hope that this tutorial will help you a lot.
If you are interested in programming, we have an example of programs that may help you even just in small ways. If you want more tutorials, you can visit our website, click here.
So what can you say about this work? Share your thoughts in the comment section below or email me at [email protected]. Practice Coding. Thank you very much.Note: Due to the size or complexity of this submission, the author has submitted it as a .zip file to shorten your download time. After downloading it, you will need a program like Winzip to decompress it.
Virus note: All files are scanned once-a-day by SourceCodester.com for viruses, but new viruses come out every day, so no prevention program can catch 100% of them.
FOR YOUR OWN SAFETY, PLEASE:
1. Re-scan downloaded files using your personal virus checker before using it.
2. NEVER, EVER run compiled files (.exe's, .ocx's, .dll's etc.)--only run source code.