ExampleMake a div element move gradually 200px down:
Try it yourself » |
The @keyframes rule is not supported in any browsers.
Safari and Chrome support an alternative, the @-webkit-keyframes rule.
With the @keyframes rule, you can create animations.
The animation is created by gradually changing from one set of CSS styles to another.
During the animation, you can change the set of CSS styles many times.
Specify when the change will happen in percent, or the keywords "from" and
"to", which is the same as 0% and 100%.
0% is the beginning of the animation, 100% is when the animation is complete.
For best browser support, you should always define both the 0% and the 100%
selectors.
Note: Use the animation properties to control the appearance of the animation, and also to bind the animation to selectors.
@keyframes { animationname keyframes-selector {css-styles;} } |
Value | Description |
---|---|
animationname | Required. Defines the name of the animation. |
keyframes-selector | Required. Percentage of the animation duration. Legal values: 0-100% Note: You can have many keyframes-selectors in one animation. |
css-styles | Required. One or more legal CSS style properties |
![]() |
Try it Yourself - Examples |
ExampleAdd many keyframe selectors in one animation:
Try it yourself » |
ExampleChange many CSS styles in one animation:
Try it yourself » |
ExampleMany keyframe selectors with many CSS styles:
Try it yourself » |