Stefan Petre

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;
    font-size: rem(16px, @remBaseSize);

Compiles to:

    font-size: 1.1429rem;

Comentarii (2)


15 apr 2014, 19:32

hello stefan
I use your slider spacegallery jquery
I'd like to have an autoplay
I don't want to need a click between the pictures.
How can I do it?
I'v tried it:
//default options (many options are controled via CSS)
defaults: {
border: 6, // border arround the image
perspective: 140, // perpective height
minScale: 0.2, // minimum scale for the image in the back
duration: 800, // aimation duration
loadingClass: null, // CSS class applied to the element while looading images
autoPlay: true, // Boolean: Animate automatically, true or false
speed: 500, // Integer: Speed of the transition, in milliseconds
delay: 4000, // Integer: Time between slide transitions, in milliseconds
before: function(){return false},
after: function(){return false}

thanks for all


23 sep 2014, 11:44

Hi Stefan,

I would like to know, how can I disable past days if I am using your DatePicker: I have tried onRender but couldn't figure it out!

Your help or hint is appreciated!

Adauga comentariu
* Campurile marcate sunt obligatorii is using cookies to personalise content and ads, to provide social media features and to analyse our traffic. I also share information about your use of my site with my social media, advertising and analytics partners.See details

By continuing to browse the site you are agreeing to my use of cookies. ✔ Continue