I want the item1 can be larger and rotate first, and then keep spinning,
however the result shows that it only excutes the animation but transform.
Thank you for your help.
In css
#item1 {
transition: transform 3s ease-in-out;
animation: spin 10s linear infinite;
animation-play-state: paused;
}
@keyframes spin{
0%{
transform: rotate(0deg);
}
100%{
transform: rotate(360deg);
}
}
In js
button.onclick = function () {
item1.style.transform = "scale(1.2) rotate(360deg)";
setTimeout(function () {
item1.style.animationPlayState = "running";
}, 3000);
};
2
Answers
You can use a
static
class and ananimate
class that also has thescale(1.2)
in thetransform
property like this:It seems there is no way to run transform "rotate and scale" in single animation keyframes. You have to create two DIVs. One for rotate and one for scale.
You can then add JavaScript "setTimeout" for some delay.