G
G
greedy_wizard2021-06-22 23:59:51
css
greedy_wizard, 2021-06-22 23:59:51

Division not working in LESS?

Here's a mixin:

.grid(@columns, @i: 1) when (@i <= @columns) {
    .col-@{i} {
        max-width: percentage(@i / @columns);
        padding: 0 @15px;
        flex: 1;
    }
    
    .grid(@columns, @i + 1);
    }
    
    .grid(@columns);


Here is the error: Error evaluating function `percentage`: argument must be a number
Please help

Answer the question

In order to leave comments, you need to log in

2 answer(s)
G
greedy_wizard, 2021-06-23
@greedy_wizard

It helped to parenthesize the division percentage((@i / @columns))

I
Ivan Bogachev, 2021-06-23
@sfi0zy

If you define @columnsand remove the dog from 15px, then everything works:

@columns: 5;

.grid(@columns, @i: 1) when (@i <= @columns) {
    .col-@{i} {
        max-width: percentage(@i / @columns);
        padding: 0 15px;
        flex: 1;
    }

    .grid(@columns, @i + 1);
}

.grid(@columns);

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question