所以我正在尝试创建一个LESS mixin,它接受一个数字(要旋转的度数),并输出正确的CSS来旋转元素。问题是,我找不到一种方法来同时编写“270deg”和“3”(270/90)以适用于IE浏览器。这里是我尝试过的方法:
.rotate(@rotation: 0) {
@deg: deg;
-webkit-transform: rotate(@rotation deg); // i can see why this doesn't work
-moz-transform: rotate((@rotation)deg); // parens
-o-transform: rotate(@rotation+deg); // variable-keyword concatenation
transform: rotate(@rotation+@deg); // variable-variable concatenation
// this is the reason I need @rotation to be just a number:
filter: progid:DXImageTransform.Microsoft.BasicImage(rotation=@rotation/90);
}
.someElement {
.rotate(270)
}
目前我只修改了编译器脚本,这样就不会在变量/关键字连接之间加入空格。但我希望有更好的解决方案。
.rotate(270deg)
?是因为IE的问题吗? - cloudhead-webkit-transform(@rotation * 1deg)
。在我的项目中,我花费了大约30分钟来尝试将@num
与%
连接起来,然后恍然大悟。只需将@num * 1%
相乘即可! - chharvey