[英]Change animation duration CSS3 not working in Chrome
I have this demo .我有这个演示。 When you click div duration animation must change but it does not work on Chrome.
当您单击 div 持续时间动画必须更改但它在 Chrome 上不起作用。
This is my js code:这是我的js代码:
var seconds = 1;
function ChangeSpeed(){
seconds++;
document.getElementById('rectangle').style.animationDuration = seconds+"s";
}
And this is my css:这是我的 css:
div#rectangle{
height:100px;
width:100px;
background:black;
-webkit-animation: ShapeRotate;
-webkit-animation-duration: 1s;
-webkit-animation-timing-function: linear;
-webkit-animation-iteration-count: infinite;
-webkit-animation-play-state: running;
}
@-webkit-keyframes ShapeRotate {
from {
-webkit-transform: rotate(0deg);
}
to {
-webkit-transform: rotate(360deg);
}
}
I also tried this demo on Firefox and it works!我也在 Firefox 上尝试了这个演示,它有效!
I can not figure out why this is not working on Chrome.我不明白为什么这在 Chrome 上不起作用。
My Chrome version is 35.0.1916.153 (Build oficial 274914) m我的 Chrome 版本是35.0.1916.153 (Build oficial 274914) m
I Think I've found your mistake.我想我已经发现了你的错误。
On your fiddle the code appears like this在你的小提琴上,代码看起来像这样
var seconds = 1;
function ChangeSpeed(){
seconds++;
document.getElementById('rectangle').style.mozAnimationDuration = seconds+"s";
}
I think that you should add compatibility to all browsers.我认为您应该添加对所有浏览器的兼容性。 Your mistake is on:
你的错误在于:
style.mozAnimationDuration
and you should put style.webkitAnimationDuration
for Chrome compatibility and so on for other browsers.并且您应该将
style.webkitAnimationDuration
放在 Chrome 兼容性等其他浏览器中。
There is a bug reported the Aug 3, 2014 : link . 2014 年 8 月 3 日报告了一个错误:链接。
It was fixed and released the Feb 2, 2015 : Blink Revision 189311 .它已在 2015 年 2 月 2 日: 闪烁修订版 189311 中修复并发布。
PS : use chrome://version/ for know your blink version. PS:使用 chrome://version/ 了解您的眨眼版本。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.