所有,我有一些代码在少做一个循环。但是,如果我将px
更改为'%',则编译较少的文件就越少。我能如何制作它?感谢。
@iterations: 100;
// helper class, will never show up in resulting css
// will be called as long the index is above 0
.loopingClass (@index) when (@index > 0) {
// create the actual css selector, example will result in
// .myclass_30, .myclass_28, .... , .myclass_1
(~".span@{index}") {
// your resulting css
width: @index px;//can not change px to % , please help me.
}
// next iteration
.loopingClass(@index - 1);
}
// end the loop when index is 0
.loopingClass (0) {}
// "call" the loopingClass the first time with highest value
.loopingClass (@iterations);
答案 0 :(得分:1)
我找到了它!
width: percentage(@index *0.01);
感谢
答案 1 :(得分:1)
很高兴你找到了解决方案。这是另一种方法:
width: @index*1%