LasseHaslev
LasseHaslev

Reputation: 33

How to use a variable with the & sign ( &-@var { ) with Less

I discovered Less for a couple of months ago and it has helped me a lot to be more efficient.

But here i have run into a problem. I think my psudocode descripes my problem. Thanks for any help! :)

.divide {
    @index:2;
    &-@index {
        @value:100/@index;
        width: ~"@{value}%";
    }
}

What I want this to be:

.divide-2 {
    width:50%;
}

Upvotes: 0

Views: 57

Answers (1)

Nicklas Nygren
Nicklas Nygren

Reputation: 2605

Try this:

@index:2;
.divide-@{index} {
    @value:100/@index;
    width: ~"@{value}%";
}

Upvotes: 3

Related Questions