繁体   English   中英

具有多个属性的css转换适用于Firefox,但不适用于chrome

[英]css transform with multiple attributes works on firefox but not in chrome

我试图添加样式变换旋转以及缩放到一组图像。 我用了

img.style = "transform: rotate(" + object[k].angle + "deg) scale(0.2);";

使用此属性可以在firefox中旋转并设置样式属性,但是在chrome上运行时它不能工作。 所以我尝试使用

img.style.webkitTransform = "rotate(" + object[k].angle + "deg) scale(0.2);";

在firefox和chrome中使用此功能时,仅缩放有效。 由于我对json中的不同图像使用了不同的旋转角度,因此很难将它们称为stylesheet.css

这是因为字符串中的分号。 Chrome将此视为您设置的样式的一部分,并认为它无效,因此将其忽略。 删除它可以在Chrome中正常运行。 更改:

img.style.webkitTransform = "rotate(" + object[k].angle + "deg) scale(0.2);";
                                                                          ^

至:

img.style.webkitTransform = "rotate(" + object[k].angle + "deg) scale(0.2)";

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM