【问题标题】:css transform with multiple attributes works on firefox but not in chrome具有多个属性的 css 转换适用于 Firefox,但不适用于 chrome
【发布时间】:2014-10-15 23:00:57
【问题描述】:

我正在尝试为一组图像添加样式变换旋转和缩放。我用过

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 的不同图像使用不同的旋转角度,我发现很难将它们调用到 style sheet.css 中作为替代

【问题讨论】:

    标签: javascript html css google-chrome firefox


    【解决方案1】:

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

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

    收件人:

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

    【讨论】:

      猜你喜欢
      • 2021-08-08
      • 2018-05-05
      • 2015-02-20
      • 1970-01-01
      • 2016-05-01
      • 1970-01-01
      • 2015-05-07
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多