3

Is it possible to add text to the parameter supplied in Less?

@parameter:20

margin: @parameter + 'px';

The output would be

margin: 20px;
Paolo Forgia
  • 6,572
  • 8
  • 46
  • 58
Rumeth
  • 63
  • 7

2 Answers2

2

You can use variable interpolation:

@parameter: 20;    
margin: ~"@{parameter}px";

Or in your case, unit built-in function can also be used:

@parameter: 20;
margin: unit(@parameter, px);

Both will result in margin: 20px;. (Working example)

juzraai
  • 5,693
  • 8
  • 33
  • 47
1
margin: @parameter * 1px;

Works perfectly for me, I´m sure this was also somewhere on stack overflow before.

Edit, found it: Negate a numerical variable and add 'px' to it in LessCSS

Doomenik
  • 868
  • 1
  • 12
  • 29