Implementing calc function using vendor prefixes in LESS
Let's make a function that implements the cross-browser CSS function calc
:
.calc(@name, @calc) {
@{name}: -webkit-calc(@calc);
@{name}: -moz-calc(@calc);
@{name}: calc(@calc);
}
Let's use our function:
div {
.calc(width, ~'10px + 30%');
}
Compilation result:
div {
width: -webkit-calc(10px + 30%);
width: -moz-calc(10px + 30%);
width: calc(10px + 30%);
}