D
D
Denis2015-09-20 00:33:49
css
Denis, 2015-09-20 00:33:49

Operations inside a LESS loop?

Good night all! Faced a problem. Organized a cycle in which for col blocks, depending on their suffixes, the width in percent will be calculated.

@gridColNumber: 12;

.grid-loop(@i) when (@i > 0) {
    [email protected]{i} {
        width: ~"((100 * @{i}) / 12)%";
    }

    .grid-loop(@i - 1);
}

.grid-loop(@gridColNumber);

respectively, the expression: width: ~"((100 * @{i}) / 12)%";does not give anything, if you write simply width: ~"@{i}%";, then it will calculate this simple expression. And when writing:
<section class="row-fluid">
            <div class="col-4"></div>
            <div class="col-4"></div>
            <div class="col-4"></div>
          </section>

col-4 blocks will be given a width of 4%, but should be according to the formula;
((100 * @{i}) / 12)%, and this is 33.33333%
Help me understand the syntax of the expression in the loop, where the width is assigned a value by the formula. Thanks in advance.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sergey, 2015-09-20
Protko @Fesor

width: (100 * @i) / 12%;
In your case, you were just collecting a string.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question