css - Always define standard Rule 'keyframe' when Defining keyframe Error

Asked

Viewed 2,520 times

3

I’m getting error in the code below that says

css - Always define standard Rule 'keyframe' when Defining keyframe Error

It runs normally on Chrome but is not working on IE 11

@-webkit-keyframes fadeIn {
  0% {
    opacity: 0;
    top: 100px;
  }
  75% {
    opacity: 0.5;
    top: 0px;
  }
  100% {
    opacity: 1;
  }
}

1 answer

2


Your problem is that you are declaring the animation only for the vendor prefix -webkit- that Chrome understands IE no more.

Animation running on IE11

inserir a descrição da imagem aqui

To fix it just add the same CSS but without the prefix @keyframes fadeIn {}

See that it will work there now without error, this is the code referring to the image above

.box {
    width: 100px;
    height: 100px;
    background-color: red;
    animation: fadeIn 1s linear infinite;
}
@-webkit-keyframes fadeIn {
  0% {
    opacity: 0;
    top: 100px;
  }
  75% {
    opacity: 0.5;
    top: 0px;
  }
  100% {
    opacity: 1;
  }
}
@keyframes fadeIn {
  0% {
    opacity: 0;
    top: 100px;
  }
  75% {
    opacity: 0.5;
    top: 0px;
  }
  100% {
    opacity: 1;
  }
}

    
<div class="box"></div>


Tip

There are details on that question that will interest you Prefixes need to be added to some CSS properties?

  • Correct. Just remove the definition of the Webkit engine that worked. Thank You!

  • @Rafaelpatriciodacruz actually if you want to ensure that the older browsers will recognize the property would be interesting to keep both @-webkit-keyframes fadeIn { } and @-webkit-keyframes fadeIn { } and if you want to go further you can still save yourself for old Firefox using @-moz-keyframes fadeIn { } (Moz = Mozilla)

  • 1

    True. Super important to address other browsers to mitigate possible compatibility failures ;)

Browser other questions tagged

You are not signed in. Login or sign up in order to post.