Answer the question
In order to leave comments, you need to log in
How to correctly write a variable in a mixin with parameters to LESS?
We have an entry in the LESS file
@color-red: #ff0000;
.addition-all(@color){
.test-1 {
background-image: url("[email protected]{color}.gif");
}
.test2 {
color: @[email protected]{color};
}
}
.red{
.addition-all(red);
}
.red .test1 {
background-image: url("bg-red.gif"); /* отработала верно */
}
.red .test1 {
color: #ff0000; /* отдает color: red; */
}
Answer the question
In order to leave comments, you need to log in
Less can only interpolate variables in selectors, strings, and property names. And there is also a construction @@
that allows you to refer to a variable by name, which lies in another variable.
@color-red: #ff0000;
.addition-all(@color) {
.test-1 {
background-image: url("[email protected]{color}.gif");
}
.test2 {
@cl: "[email protected]{color}";
color: @@cl;
}
}
.red {
.addition-all(red);
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question