Repository navigation
Keyframes
Keyframes make your website come alive! Using @keyframe, you can create an animation by giving it a specific time, property and value. You will need to give your animation a name, so you can use it on elements. This is what it should look like:
@keyframes dropDown {
0% {
transform: translateY(-130%);
}
10% {
transform: translateY(-50%);
}
20% {
transform: translateY(-60%);
}
30% {
transform: translateY(-50%);
}
40% {
transform: translateY(-57%);
}
50% {
transform: translateY(-50%);
}
60% {
transform: translateY(-55%);
}
70% {
transform: translateY(-50%);
}
80% {
transform: translateY(-53%);
}
90% {
transform: translateY(-50%);
}
100% {
transform: translateY(-130%);
}
}We first call the query @keyframes and give the animation a name. Now we can add a specific time and edit the property's value at the given time. When calling the animation, we can add some more options like time and speed.
.hanging-man {
animation: dropDown 5s ease-in-out;
}I think percentage is the easiest way to create a nice animation, but if you want to do something more simple you can make use of the from-to timestamp.
@keyframes rotate {
from {
transform: rotate(0deg)
}
to {
transform: rotate(360deg);
}
}You don't even have to use from, since the element is already 0deg by default. Instead we only have to tell the animation where to go.
@keyframes rotate {
to {
transform: rotate(360deg);
}
}