【发布时间】:2016-11-19 03:24:08
【问题描述】:
我已阅读 Less#loops 和 Less#functions 文档。
但我不知道如何应用percentage 函数,或类似的方法来逐步循环百分比而不使用此类函数。
当我在另一个循环中计算它时,正如另一个 post width: percentage(140/620); 中指出的那样,它可以工作,但在尝试使用变量循环时却不行。
在 2014 年,@pixelass 建议使用外部 library 来更轻松地循环,但我不想使用外部库。
我要循环的内容(甚至不编译):
.loop (@n, @index: 0) when (@index < @n) {
percentage(@index * (100/@n)){ // This line is messing up my day.
// code
}
.loop(@n, (@index + 1)); // Next iteration.
}
@keyframes anim {
.loop(20); // Launch the loop.
}
我正在尝试将这个 Sass 翻译成 Less:
@keyframes anim{
$steps:20;
@for $i from 0 through $steps{
#{percentage($i*(1/$steps))}{
// code
}
}
}
【问题讨论】:
-
我正在尝试将此 SASS 翻译为 LESS:
@keyframes anim{ $steps:20; @for $i from 0 through $steps{ #{percentage($i*(1/$steps))}{ // code } } }
标签: css loops animation less css-animations