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,202
  • 8
  • 42
  • 57
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,340
  • 8
  • 31
  • 45
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
  • 848
  • 1
  • 12
  • 28