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

108
Visualizações
how to re-execute animation when animation ends

In the project design, 4 coins are supposed to be stacked on top of each other for 2 seconds with a delay of 0.5 seconds. (According to the code mentioned). I want the re-animation to start automatically when the 4-second period is over.Is it possible to do this without JavaScript and using Css?

Thank you in advance for your cooperation

.Coins > img{
    width: auto;
    opacity: 0;
    position: absolute;
    animation:  appear 2s linear infinite backwards;
    -webkit-animation:  appear 2s linear infinite backwards;
}

.Coins > img:nth-child(1){
    top: 50%;
    left: 40%;
    animation-delay: 0.5s;
}

.Coins > img:nth-child(2){
    top: 47%;
    left: 41%;
    animation-delay: 1s;
}

.Coins > img:nth-child(3){
    top: 44%;
    left: 39%;
    animation-delay: 1.5s;
}

.Coins > img:nth-child(4){
    top: 41%;
    left: 40%;
    animation-delay: 2s;
} 


@keyframes appear{
    0% {
        opacity: 0;
    }
    100% {
        opacity: 1;
    }
}

@-webkit-keyframes appear{
    0% {
        opacity: 0;
    }
    100% {
        opacity: 1;
    }
}
<div class="Coins">
    <img src="coin.png" alt="">
    <img src="coin.png" alt="">
    <img src="coin.png" alt="">
    <img src="coin.png" alt="">
</div>

]1]1

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

0

You can do this just using CSS, but notice that the overall time for the animation of a single coin has to be 4seconds, not 2. For 2 of those seconds it is appearing from opacity 0 to opacity 1 and then it disappears to opacity 0 immediately (that is the effect of the backwards parameter in the animation).

So, the animation needs to have 50% of the time increasing the opacity, then 50% with the opacity 0.

.Coins>img {
  width: auto;
  opacity: 0;
  position: absolute;
  animation: appear 4s linear infinite backwards;
  width: 10vmin;
  height: 2vmin;
  background: gold;
}

.Coins>img:nth-child(1) {
  top: 50%;
  left: 40%;
  animation-delay: 0.5s;
}

.Coins>img:nth-child(2) {
  top: 47%;
  left: 41%;
  animation-delay: 1s;
}

.Coins>img:nth-child(3) {
  top: 44%;
  left: 39%;
  animation-delay: 1.5s;
}

.Coins>img:nth-child(4) {
  top: 41%;
  left: 40%;
  animation-delay: 2s;
}

@keyframes appear {
  0%,
  50.001%,
  100% {
    opacity: 0;
  }
  50% {
    opacity: 1;
  }
}
<div class="Coins">
  <img src="coin.png" alt="">
  <img src="coin.png" alt="">
  <img src="coin.png" alt="">
  <img src="coin.png" alt="">
</div>

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