首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >CSS3动画在Chrome中不工作,而在Firefox中工作

CSS3动画在Chrome中不工作,而在Firefox中工作
EN

Stack Overflow用户
提问于 2015-12-04 20:09:36
回答 2查看 494关注 0票数 0

以下代码在Chrome 47中不工作,在Firefox 42中也正常工作:

代码语言:javascript
复制
@-webkit-keyframes hue {
  from { -webkit-filter: hue-rotate(0deg);    }
  to   { -webkit-filter: hue-rotate(-360deg); }
}

@-moz-keyframes hue {
  from { -moz-filter: hue-rotate(0deg);    }
  to   { -moz-filter: hue-rotate(-360deg); }
}

@-ms-keyframes hue {
  from { -ms-filter: hue-rotate(0deg);    }
  to   { -ms-filter: hue-rotate(-360deg); }
}

@-o-keyframes hue {
  from { -o-filter: hue-rotate(0deg);    }
  to   { -o-filter: hue-rotate(-360deg); }
}

@keyframes hue {
  from { filter: hue-rotate(0deg);    }
  to   { filter: hue-rotate(-360deg); }
}

.change-hue-animation {
  -webkit-animation: hue 60s infinite linear;
  -moz-animation: hue 60s infinite linear;
  -ms-animation: hue 60s infinite linear;
  -o-animation: hue 60s infinite linear;
  animation: hue 60s infinite linear;
}

为什么?我是不是做错了?

提前谢谢。

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2015-12-04 20:26:24

你写的大部分语法甚至都不存在。而且-webkit-关键帧现在被废弃了。使用它在所有浏览器上运行:

代码语言:javascript
复制
.change-hue-animation {
  animation: hue 60s infinite linear;
  -webkit-animation: hue 60s infinite linear;
}

@keyframes hue {
  from { filter: hue-rotate(0deg);  -webkit-filter: hue-rotate(0deg);  }
  to   { filter: hue-rotate(-360deg);-webkit-filter: hue-rotate(-360deg); }
}

演示:http://jsfiddle.net/790gzz83/4/

票数 2
EN

Stack Overflow用户

发布于 2015-12-04 20:20:40

我相信你的动画不会在铬中触发,因为它选择的是@keyframes hue而不是@-webkit-keyframes hue。在这种情况下,它不会到达-webkit-filter: hue-rotate,而是使用来自@keyframesfilter: hue-rotate

@keyframes下,将filter更改为-webkit-filter将在chrome:小提琴中工作。

您可以将过滤器组合成一个@keyframes,例如:

代码语言:javascript
复制
@keyframes hue {
  from {
    -webkit-filter: hue-rotate(0deg);
    filter: hue-rotate(0deg);
  }
  to {
    -webkit-filter: hue-rotate(-360deg);
    filter: hue-rotate(-360deg);
  }
}

.change-hue-animation {
  animation: hue 10s infinite linear;
  -webkit-animation: hue 10s infinite linear; /* Android, Safari/Safari Mobile support */
}
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/34096618

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档