Prev Demo
Animation Direction
Next Demo
Write code here
J
|
B
|
A
<!DOCTYPE html> <html> <head> <title></title> <style> div { width: 100px; height: 100px; background: red; position: relative; /* for chrome and safari*/ -webkit-animation: animate 2s infinite; -webkit-animation-direction: alternate-reverse; /* for safari*/ -moz-animation: animate 2s infinite; -moz-animation-direction: alternate-reverse; /*for opera*/ -o-animation: animate 2s infinite; -o-animation-direction: alternate-reverse; /* Standard syntax */ animation: animate 2s infinite; animation-direction: alternate-reverse; } @-webkit-keyframes animate { 0% { background: green; left: 0px; top: 0px; } 50% { background: pink; left: 200px; top: 200px; } 100% { background: blue; left: 0px; top: 0px; } } @-moz-keyframes animate { 0% { background: green; left: 0px; top: 0px; } 50% { background: pink; left: 200px; top: 200px; } 100% { background: blue; left: 0px; top: 0px; } } @-o-keyframes animate { 0% { background: green; left: 0px; top: 0px; } 50% { background: pink; left: 200px; top: 200px; } 100% { background: blue; left: 0px; top: 0px; } } @keyframes animate { 0% { background: green; left: 0px; top: 0px; } 50% { background: pink; left: 200px; top: 200px; } 100% { background: blue; left: 0px; top: 0px; } } </style> </head> <body> <h2>Animation direction</h2> <div></div> </body> </html>
Note: We DO NOT save your trial code in our database.
Output