Note: Using Less mixins for vendor prefixing is not good practice and this answer does not make any attempts to recommend it. It only provides a straight answer to the question that was asked. If you are interested in knowing the recommended approach for vendor prefixing, have a loot at Bass Jobsen's answer in this thread.
Why does your mixin call not work?
Whenever a mixin call is made, Less only invokes the mixin if all the parameters have a value (either a default value or a value passed in the mixin call).
In this case, the bootstrap translate
mixin has 2 parameters (with no default values) and the mixin call has only one parameter. Because of this, the mixin would never get invoked/processed.
What is the solution to the problem?
In order to overcome this, you could just pass 0
(or 0%
) to the @x
parameter like
.translate(@x; @y) {
-webkit-transform: translate(@x, @y);
-ms-transform: translate(@x, @y); // IE9 only
-o-transform: translate(@x, @y);
transform: translate(@x, @y);
}
div{
.translate(@x: 0%;@y: 50%);
}
This would produce an output which is essentially equivalent to a translation only in Y axis (as can be seen in this simple sample).
The below is the output
div {
-webkit-transform: translate(0%, 50%);
-ms-transform: translate(0%, 50%);
-o-transform: translate(0%, 50%);
transform: translate(0%, 50%);
}
and it is equivalent to
div {
-webkit-transform: translateY(50%);
-ms-transform: translateY(50%);
-o-transform: translateY(50%);
transform: translateY(50%);
}