Build a repetitive selector within a Less loop

前端 未结 2 909
一生所求
一生所求 2021-01-15 05:16

I\'ve seen various ways of looping in LESS, but I haven\'t found a way to build selectors (agglutinate would be the right term I guess).

For example, I\'d like somet

2条回答
  •  甜味超标
    2021-01-15 05:46

    The proper solution would be:

    .staticClass {
        .loop(5);
        .loop(@n, @i: 1) when (@i <= @n) {
            .repeatedClass {
                > .finalStaticClass {
                    height: 10px * @i;
                }
                .loop(@n, @i + 1);
            }
        }
    }
    

    Demo.

提交回复
热议问题