- Tags: Animation
- Categories: CSS Reference, CSS Resources, Reference
Quick Reference
The @keyframes rule defines the animation timeline, which gradually changes from one set of CSS styles to another.
The @keyframes rules specifies when the style changes will happen in percent, or with 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 has completed.
Moving an Element
@keyframes my_animation {
from {
top: 0px;
}
to {
top: 500px;
}
}
@keyframes my_animation {
0% {
top: 0px;
}
25% {
top: 500px;
}
50% {
top: 250px;
}
75% {
top: 500px;
}
100% {
top: 0px;
}
}
Changing Multiple CSS Values
@keyframes my_animation {
from {
top: 0px;
background: red;
}
to {
top: 500px;
background: blue;
}
}
Values
These are the allowed values.
Value | Description |
---|---|
animationname | Defines the name of the animation (required) |
keyframes-selector | Percentage of the animation duration (required)
|
css-styles | One or more legal CSS style properties (required) |
We’d like to acknowledge that we learned a great deal of our coding from W3Schools and TutorialsPoint, borrowing heavily from their teaching process and excellent code examples. We highly recommend both sites to deepen your experience, and further your coding journey. We’re just hitting the basics here at 1SMARTchicken.
Why 1SMARTchicken?
See More →
Thanks for your support!
CSS Books
All are affiliate links. Thank you for your support!
CSS NOTES:
- The “inherit”, “initial” and “unset” keywords can be used with any CSS property to set its value
- In CSS there are many ways to express a color value in a property
Feedback
If you see an error on the page or the code itself is incorrect or incomplete, or just plain wrong, please let us know. We’re always learning. NOTE: we do not sell your information and will not send you spam emails.