I'm fiddling around with 3D CSS animations, and I've run into an issue where I have a moving element which is being translated on the X-axis. This transformation runs for 2 seconds. However, I also want to apply a rotation to the element on the Y-axis which runs for 30 seconds.
The problem I am running into is that since translate and rotate are both part of the transform property in CSS, there doesn't seem to be a way in which I can apply separate timings to each of them.
.ball {
position: absolute;
left: 50%;
top: 50%;
width: 50px;
height: 50px;
border-radius: 50%;
background-color: red;
animation: animate 2s infinite linear;
}
@keyframes animate {
to {
transform: translateX(100px) rotateY(360deg);
}
}
<html>
<body>
<div class="ball"></div>
</body>
</html>
As you can see, I'm able to make the ball both translate and rotate at the same time, but I cannot figure out how to apply separate timings to each animations. Again, I want the translation to be a 2 second animation, but the rotation I want to be a 30 second animation. Is this possible?