search

Home  >  Q&A  >  body text

前端 - 请问@keyframes当中都要写默认的吗?

@-webkit-keyframes loading {
    0% {
        -webkit-transform: rotate(0deg);
        transform: rotate(0deg);
    }
    100% {
        -webkit-transform: rotate(360deg);
        transform: rotate(360deg);
    }
}

有这样一段代码定义了一个动画loading,那么定义这个keyframes的时候已经加上了-webkit-前缀了,还需要在代码当中写那个不加前缀的transform吗?

PHPzPHPz2768 days ago998

reply all(1)I'll reply

  • 大家讲道理

    大家讲道理2017-04-17 11:26:07

    It is only for compatibility with older versions of -webkit- kernel browsers
    If you are sure that the browser is old enough, you can use it directly -webkit-transform: rotate(0deg);.
    If you are sure that the browser is new enough, you can use it directly transform: rotate(0deg);
    New browsers will recognize it first transform: rotate(0deg);

    至于底层没有深究 但是应该是 `-webkit-transform`是对性的消耗应该是超过 
    `transform` 所以新旧一般都同时写上(这个等我查了相关api再补充)
    

    reply
    0
  • Cancelreply