using javascript calculated values in less

前端 未结 7 1476
无人及你
无人及你 2020-12-18 00:01

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

7条回答
  •  抹茶落季
    2020-12-18 00:22

    try this

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

    because .height() returns only unit-less pixel value.
    alternatively use the following

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

    .css("height") returns a value with units

提交回复
热议问题