1. When in
@keyframesCreate an animation, bind it to a selector, or the animation will have no effect.
Specifies that at least these two CSS3 animated properties are bound to a selector:
- Specify the name of the animation
- Specify the duration of the animation
Div {
animation: myfirst 5s
-webkit-animation: myfirst 5s; /* Safari with Chrome * /
}
2. Animations are effects that gradually change an element from one style to another.
You can change any number of styles any number of times.
Use percentages to specify when changes occur, or use the words "from" and "to", equivalent to 0% and 100%.
0% is the beginning of the animation, and 100% is the completion of the animation.
For best browser support, you should always define the 0% and 100% selectors.
Example:
Change the background color when the animation is 25% and 50%, then change it again when animation 100% finishes
@keyframes myfirst {
0% {background: red;}
< Span class= "Hl-var" > 25% {background: yellow /span>
< Span class= "Hl-var" > < Span class= "hl-reserved" > 50% {background: blue;}
< Span class= "hl-brackets" > < Span class= "Hl-code" > & nbsp 100% {background: green;}
}
< Span class= "Hl-code" > < Span class= "hl-brackets" > @-webkit-keyframes myfirst /* safari and Chrome */
< Span class= "Hl-code" > { 0% {background:< Span class= "Hl-code" > red;
< Span class= "hl-brackets" > 25% {background: yellow;"
< Span class= "hl-brackets" > < Span class= "Hl-code" > & nbsp 50% {background: blue;}
< Span class= "hl-brackets" > < Span class= "Hl-code" > & nbsp 100% {background: green;}
}
@keyframes: Specify animation
Animation: short for all animated properties
Animation-name: Animated Name
CSS style animations