问题
Below is example less mixin code
.mixin(@option) {
.set(@options) when (@options = a){
@type: linear;
}
.set(@option);
background: -webkit-~'@{type}'-gradient(...);
}
The output
background: -webkit- linear -gradient(...);
How can i remove the space around linear
?
回答1:
Less does not support an inplace concatenation via variable interpolation in value statements. You need a temporary variable for this (+ an auxiliary variable in this particular case to handle parens), e.g.:
@end-func: ~')';
div {
@func: ~'-webkit-@{type}-gradient(';
background: @func ... @end-func;
}
回答2:
Try the following:
[less function]
.transition(@propValue) {
-moz-transition: e(%("-moz-%a", @propValue));
-webkit-transition: e(%("-webkit-%a", @propValue));
-ms-transition: e(%("-ms-%a", @propValue));
transition: @propValue;
}
[css]
.transition(e("transform 0.5s ease"));
[The output]
-moz-transition: -moz-transform 0.5s ease;
-webkit-transition: -webkit-transform 0.5s ease;
-ms-transition: -ms-transform 0.5s ease;
transition: transform 0.5s ease;
来源:https://stackoverflow.com/questions/31779829/remove-space-when-less-variable-value-to-string