Answer the question
In order to leave comments, you need to log in
How to reassign a variable in LESS depending on a condition?
I enter a variable with color. And depending on the condition in the mixin, I change it.
@value: true;
@color: #000;
.change-color() when (@value = true) {
@color: #fff;
}
.change-color();
Answer the question
In order to leave comments, you need to log in
Because the variables are declared in different scopes.
As an option to do this:
@value: true;
.mixin (@color) {
// Тут все правила, использующие @color...
}
& when (@value = false) {
.mixin(#000);
}
& when (@value = true) {
.mixin(#FFF);
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question