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

160
Visualizações
CSS animation rendering inconsistently on iOS

I'm trying to make a div repeatedly appear instantly and slowly fade-out, at arbitrary intervals.

JS used to make the div appear:

div.classList.remove('fade-out');
div.offsetWidth;
div.classList.add('fade-out');

With this CSS:

.fade-out {
    animation: fadeOut 2.5s ease-out;
}

@keyframes fadeOut { from { opacity: 1; } to { opacity: 0; } }

div { opacity: 0; }

For some reason, this works as expected in desktop Chrome, Safari & Firefox, but on iOS around half of the time the animation isn't played — the div just disappears after 2.5 seconds with no progressive opacity change. This happens both on both iPhone and iPad, with both Firefox and Safari.

Stuff tried since the initial post:
  • Add animation: none to the element's original definition.
  • Set the animation property through JS instead.
  • Use 100% and 0% instead of to and from.
  • Setting the div's initial opacity to 1 instead of 0 and add animation-fill-mode: forward.
  • Add a short delay with setTimeOut.
  • Use full animation definition instead of shorthand notation.
  • Additional definition using -webkit-animation and @-webkit-keyframes.

Using any of the above doesn't have an effect on the animation, which still works as expected everyhere except on iOS.

(Not a real) solution

The only way I could make iOS display the animation consistently was by adding a short delay to the animation:

animation: fadeOut 2.5s ease-out 0.01s

However, since the div's "instant display then fade-out" animation can be triggered while an old animation is still running on it, the delay adds a noticeable one-frame flash which is undesirable (regardless of how low I set the delay value).

Any ideas?

about 4 years ago · Juan Pablo Isaza
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