1
I have a box that moves to one side and to the other using translateX ai I put a pseudo class to emulate a jump with translateY when the user hovers over the parent container of this box. The problem is that no matter where the box is on the x-axis, when it jumps it always jumps on the x-axis 0px. If you jump using the top property it works, but using translateY causes this strange behavior.
#mundo{
width: 600px;
height: 400px;
position: relative;
margin: 0px auto;
background: cornsilk;
}
#caixa{
position: absolute;
width: 50px;
height: 50px;
outline: 1px solid;
left:0px;
top:100px;
animation: mover 3s alternate infinite;
}
#mundo:hover #caixa{
animation:mover 3s alternate infinite, pular 1s;
}
@keyframes mover{
0%{transform:translateX(-10px)}
100%{transform:translateX(500px)}
}
@keyframes pular{
0%{transform:translateY(0px)}
50%{transform:translateY(-50px)}
100%{transform:translateY(0px)}
}
/*Esa versao do pulo funciona - THS version works */
/*
@keyframes pular{
0%{top:100px}
50%{top:50px}
100%{top:100px}
}
*/
<div id="mundo">
<div id="caixa"></div>
</div>