Implementering af calc-funktionen med brug af vendor-prefiks i LESS
Lad os lave en funktion, der implementerer
den cross-browser CSS-funktion calc:
.calc(@name, @calc) {
@{name}: -webkit-calc(@calc);
@{name}: -moz-calc(@calc);
@{name}: calc(@calc);
}
Lad os bruge vores funktion:
div {
.calc(width, ~'10px + 30%');
}
Kompileringsresultat:
div {
width: -webkit-calc(10px + 30%);
width: -moz-calc(10px + 30%);
width: calc(10px + 30%);
}