I have a two animations, one is a default animation that rotates a div on the z axis
, and when you hover over the div, I have it scale up and down as well.
Is there a way for me to animate between the two animations? Currently if the animation is half way through, and I hover over the div it applies the new animation from the beginning, and it looks strange. I would like it to seamlessly go between animations is that possible?
.chest {
height: 64px;
width: 64px;
background: yellow;
animation: rocking-chest 2s linear infinite;
margin-left: 50px;
margin-top: 50px;
}
.chest:hover {
animation: rocking-pulse-chest 1s linear infinite;
}
@keyframes rocking-chest {
0% {
transform: rotateZ(-20deg);
}
50% {
transform: rotateZ(20deg);
}
100% {
transform: rotateZ(-20deg);
}
}
@keyframes rocking-pulse-chest {
0% {
transform: rotateZ(-20deg) scale(1);
}
50% {
transform: rotateZ(20deg) scale(1.5);
}
100% {
transform: rotateZ(-20deg) scale(1);
}
}
<div class="chest"></div>