简体   繁体   English

无效的属性值CSS旋转

[英]Invalid property value CSS rotate

I created a class and I am trying to rotate 45 degrees in CSS, but Chrome says "Invalid property value" 我创建了一个类,并尝试在CSS中旋转45度,但Chrome提示“无效的属性值”

 .cr { background-color: #444; position: absolute; left: 5px; top: 13.5px; width: 20px; height: 3px; -o-webkit-transform: rotate(45deg); -o-moz-transform: rotate(45deg); -o-ms-transform: rotate(45); transform: rotate(45deg); } 
 <div class="cr"></div> 

Why is this happening?? 为什么会这样?

You don't need the o-webkit. 您不需要o-webkit。
o stands for Opera, webkit is the engine behind Chrome. o代表Opera,webkit是Chrome背后的引擎。

It's simply -webkit-transform: rotate(45deg); 只是-webkit-transform: rotate(45deg);

Same with the moz prefix. 与moz前缀相同。

Correct is 正确的是

/* Transform */
-webkit-transform:rotate(45deg);
   -moz-transform:rotate(45deg);
    -ms-transform:rotate(45deg);
     -o-transform:rotate(45deg);
        transform:rotate(45deg);

Check out caniuse.com which prefixes are needed for which browsers or use a service like http://prefixmycss.com/ . 查看caniuse.com ,哪些浏览器需要哪些前缀,或使用诸如http://prefixmycss.com/之类的服务。

On caniuse.com click "Show all" to see more than the last few versions. 在caniuse.com上,单击“显示全部”以查看除最后几个版本以外的更多内容。 You probably want to keep the Opera prefixes although it's not needed in recent versions but version 12 which is still quite popular requires them. 您可能想保留Opera前缀,尽管在最新版本中不需要,但是仍然非常流行的版本12需要使用Opera前缀。

Even better would be an automation tool like grunt but that is out of scope for this question. 更好的是像grunt这样的自动化工具,但这在这个问题之外。

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

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