简体   繁体   English

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

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

I'm trying to add style transform rotate as well as scale to a set of images. 我试图添加样式变换旋转以及缩放到一组图像。 I used 我用了

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

Using this the transform attribute rotate and style work fine in firefox, but when running on chrome it dooesnt work. 使用此属性可以在firefox中旋转并设置样式属性,但是在chrome上运行时它不能工作。 So I tried using 所以我尝试使用

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

While using this in firefox and chrome only the scaling works. 在firefox和chrome中使用此功能时,仅缩放有效。 Since I am using different rotation angles for different image from a json I'm finding it difficult to call them into style sheet.css as an alternative 由于我对json中的不同图像使用了不同的旋转角度,因此很难将它们称为stylesheet.css

It's because of the semicolon within the string. 这是因为字符串中的分号。 Chrome treats this as part of the style you're setting and ignores it as it believes it to be invalid. Chrome将此视为您设置的样式的一部分,并认为它无效,因此将其忽略。 Removing it works fine in Chrome. 删除它可以在Chrome中正常运行。 Change: 更改:

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

To: 至:

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