相关疑难解决方法(0)

在没有空格的情况下以较小(css)连接值

所以我试图制作一个LESS mixin,它取一个数字(旋转度)并输出正确的css来旋转元素.问题是,我无法找到一种方法来为IE写"270deg"和"3"(270/90).以下是我尝试过的事情:

.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)
}
Run Code Online (Sandbox Code Playgroud)

现在我刚刚修改了编译器脚本,以便它不会在变量/关键字连接之间放置空格.我希望有更好的解决方案.

css less

28
推荐指数
2
解决办法
1万
查看次数

将单位添加到较小的变量

如果我有行高的数值LESS变量

@lineHeight: 1.2
Run Code Online (Sandbox Code Playgroud)

如何将em添加到其末尾以设置要生成的元素的高度:

height: 1.2em;
Run Code Online (Sandbox Code Playgroud)

以下不起作用:

height: @(lineHeight)em;
height: @(lineHeight)"em";
height: @(lineHeight) + "em";
height: @lineHeight + "em";
Run Code Online (Sandbox Code Playgroud)

我已经看到其他线程,答案是添加一个单位并不容易,但这似乎并不正确,因为数字线高值与em单位齐头并进.

css less

6
推荐指数
1
解决办法
1787
查看次数

标签 统计

css ×2

less ×2