Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Add units to a less variable

Tags:

css

less

If I have a numerical LESS variable for line-height

@lineHeight: 1.2

how do I add em to the end of it to set the height of the element to produce:

height: 1.2em;

The following do not work:

height: @(lineHeight)em;
height: @(lineHeight)"em";
height: @(lineHeight) + "em";
height: @lineHeight + "em";

I have seen other threads where the answer is adding a unit is not easy, but that doesn't seem right as the numerical line-height value goes hand in hand with the em unit.

like image 279
Tahsis Claus Avatar asked May 06 '15 21:05

Tahsis Claus


1 Answers

I found a solution in a shopware theme-mixin

 height: ~"@{lineHeight}px";

But the solution from seven-phases-max in your comments works too

 height: unit(@lineHeight, px);
like image 83
Radon8472 Avatar answered Sep 25 '22 01:09

Radon8472