Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

124
Visualizações
Start animation from right when leaving screen

I want to have an animation that starts in the center but loops infinitely. As you can see in the snippet the cubes first start in the center, dispersed evenly across the width, but what I want is that the moment the cube leaves the screen on the left, it starts back at the right, so it is seamless. Anyone knows how to do this?

Here's the code:

#skillIcon {
  animation: moveLeft 5s linear infinite;
  width:100px;
  height:100px;
  background-color:#444;
  align-items:center;
  position:relative;
}

@-webkit-keyframes moveLeft {
  from {
    right: -30%;
  }
  to {
    right: 100%;
  }
}

#parentDiv{
background-color:#222;
display:flex;
position:relative;
justify-content:space-between;
align-items:center;
}
<div id="parentDiv">
<div id="skillIcon">
</div>
<div id="skillIcon">
</div>
<div id="skillIcon">
</div>
</div>

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

you're on the right track, the keys frames is the trick

@keyframes example {
  0%   {left:50%;}
  50% {left:-30%;}
  50.01% {left:130%;}
  100%  {left:50%;}
}

div {
  width: 10px;
  height: 10px;
  position: relative;
  left:50%;
  background-color: red;
  animation: example 4s linear infinite;
}

edited:

I found a better solution Using just 2 keyframes and setting delay you can have it start anywhere on the screen.

@keyframes example {
  0%   {left:110%;}
  100%  {left:-10%;}
}

div {
  width: 10px;
  height: 10px;
  position: relative;
  left:0%;
  background-color: red;
  animation: example 4s linear infinite;
}

then ethier in css on on the div itself set a delay -2 secs on a 4 secs loop will start in the centre of element.

<div style="animation-delay:-2s"/>
about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda