I want to animate two (or more) css conversion properties separately, using keyframe animation as follows:
@keyframes translatex { 100% { transform: translateX(100px); } } @keyframes rotatez { 100% { transform: rotateZ(80deg); } }
HTML:
<div class="rect"></div>
translatex animation should start with a delay of 0 seconds and last 5 seconds. The rotatez animation should start with a delay of 1 s and last 3 seconds. Thus, the correct element begins to move, and then after 1 second it starts to rotate, and then after 3 seconds it stops rotating and after 1 second it ends its movement.
Apply animation:
.rect { animation-name: translatex, rotatez; animation-duration: 5s, 3s; animation-timing-function: ease, ease-in-out; animation-delay: 0s, 1s; animation-direction: forward, forward; }
The problem is that only rotatez animation is applied. My question is: are there any ways to implement such an animation using only css (keyframe animation, transitions), or do I need JS and requestAnimationFrame?
EDIT :: my FIDDLE
css animation transform css-animations
Dmitry
source share