1
Look at this image above. I’m trying to get these two objects to start from the right and go to the left until they disappear from the screen.
I want one to stay behind the other, without knocking, without overlapping and I can’t.
Code below:
img.trator-rodape {
display: block;
position: absolute;
transform: translateX(1980px);
bottom: 10px;
width: 20%;
max-width: 333px;
animation-name: TratorRodape;
animation-duration: 45s;
animation-iteration-count: infinite;
}
img.caminhao {
display: block;
position: absolute;
transform: translateX(2380px);
bottom: 16px;
width: 20%;
max-width: 164px;
animation-name: CaminhaoRodape;
animation-duration: 135s;
animation-iteration-count: infinite;
}
// Trator
@keyframes TratorRodape {
10% {
transform: translateX(1500px);
}
20% {
transform: translateX(1000px);
}
30% {
transform: translateX(700px);
}
50% {
transform: translateX(500px);
}
70% {
transform: translateX(300px);
}
90% {
transform: translateX(0px);
}
100% {
transform: translateX(-500px);
}
}
// Caminhão
@keyframes CaminhaoRodape {
10% {
transform: translateX(1500px);
}
20% {
transform: translateX(1000px);
}
30% {
transform: translateX(700px);
}
50% {
transform: translateX(500px);
}
70% {
transform: translateX(300px);
}
90% {
transform: translateX(0px);
}
100% {
transform: translateX(-200px);
}
}
It has to be an infinite animation.
you can use percentage in Translate (translateX(10%)) increasing up to 100%
– Iago Correia Guimarães
I have. To start when I use
translateX(100%)
he’s not totally on the right...– Diego Souza