All of the Less mixins I have found for gradients have only a fixed number of stops. The clash between less and css in the use f the comma makes variable stops impossible to do in the same way.
Current mixin that I use for 2 way gradients
.gradient (@origin: left, @step-1: @white, @step-2: @black, @fallback: @step-1){
background-color: @fallback;
background: -webkit-linear-gradient(@origin, @step-1, @step-2) @fallback no-repeat;
background: -moz-linear-gradient(@origin, @step-1, @step-2) @fallback no-repeat;
background: -ms-linear-gradient(@origin, @step-1, @step-2) @fallback no-repeat;
background: -o-linear-gradient(@origin, @step-1, @step-2) @fallback no-repeat;
background: linear-gradient(@origin, @step-1, @step-2) @fallback no-repeat;
}
and for 3 way
.gradient-3-way (@origin: left, @step-1: @white, @step-2: @black, @step-3: @white, @fallback: @step-1){
background-color: @fallback;
background: -webkit-linear-gradient(@origin, @step-1, @step-2, @step-3) @fallback no-repeat;
background: -moz-linear-gradient(@origin, @step-1, @step-2, @step-3) @fallback no-repeat;
background: -ms-linear-gradient(@origin, @step-1, @step-2, @step-3) @fallback no-repeat;
background: -o-linear-gradient(@origin, @step-1, @step-2, @step-3) @fallback no-repeat;
background: linear-gradient(@origin, @step-1, @step-2, @step-3) @fallback no-repeat;
}
You have to pull your gradient styles into the mixin call using a separate variable.
No Separate Variable Needed
All that you need is to make sure you use a semicolon as a separator for the parameters, even if that happens to just be only one parameter you are passing. So this works:
LESS
CSS Output