Skip to content Skip to sidebar Skip to footer

Using Javascript Calculated Values In Less

In LESS I used following code to get the window's height. @winheight:`$(window).height()` What I'm getting is a number, but when i add px there to have the unit, height: @winheigh

Solution 1:

Simply use string interpolation and then escape from the string using ~:

@winheight:`$(window).height()`;

height: ~"@{winheight}px";

Solution 2:

Take .css(height) instead of .height() - this returns the value + unit.

Solution 3:

give this code and see what is you get it.

@winheight:0px + `$(window).height()'

Solution 4:

Does replacing empty space help for you? Try reading the answer of this: Replacing spaces with underscores in JavaScript?

Solution 5:

What about this:

@winheight:`$(window).height().toString() + "px"`

Post a Comment for "Using Javascript Calculated Values In Less"