Rem converter for Less CSS
It's a small hack that adds a function to convert px into rem.
Find inside less.js or functions.js:
convert: function (val, unit) { return val.convertTo(unit.value); },
and right after add:
rem: function (val, base) { var remSize = Math.round((val.value/base.value)*10000)/10000; return new(tree.Dimension)(remSize, 'rem'); },
And now you can convert px to rem. The following Less:
@remBaseSize: 14px; .class{ font-size: rem(16px, @remBaseSize); }
Compiles to:
.class{ font-size: 1.1429rem; }