1<style>
2@keyframes animatename{
3 0%{
4 transform: translateY(3px);
5 }
6 100%{
7 transform: translateY(-3px);
8 }
9}
10.my-div{
11 animation: animatename 1s linear infinite;
12 /* animation shorthand */
13 animation: animation-name animation-duration animation-direction animation-iteration-count
14}
15</style>
1<style>
2.my-element {
3 width: 100%;
4 height: 100%;
5 animation: tween-color 5s infinite;
6}
7
8@keyframes tween-color {
9 0% {
10 background-color: red;
11 }
12 50% {
13 background-color: green;
14 }
15 100% {
16 background-color: red;
17 }
18}
19
20html,
21body {
22 height: 100%;
23}
24<style>
25
26<body>
27 <div class="my-element"></div>
28</body>
1animation: name time func delay iteration dir fill play;
2animation: none 0s ease 0s 1 normal none running;
1body{
2background-color: purple;
3}
4
5@keyframes party{
6 0% {background-color: red;}
7 10% {background-color: orange;}
8 20% {background-color: yellow;}
9 30% {background-color: green;}
10 40% {background-color: blue;}
11 50% {background-color: purple;}
12}
13
14@-webkit-keyframes party{
15 0% {background-color: red;}
16 10% {background-color: orange;}
17 20% {background-color: yellow;}
18 30% {background-color: green;}
19 40% {background-color: blue;}
20 50% {background-color: purple;}
21}
1function party(){
2 document.body.style.animation = 'party 2.5s infinite linear';
3}
1<html>
2 <body id="bd">
3 <button onclick="party()">Press Me!</button>
4 </body>
5
6
7</html>