Thibaut
Thibaut

Reputation: 182

Variable Properties in LESS CSS

I am trying to create me a PX/REM converter in LESS CSS but I am facing a problem. The following lines do not want to compile, the problem comes from @{propertyValue}:.

.rem(@propertyValue; @sizeValue) {
  @remValue: @sizeValue / unit(@base-font-size);
  @{propertyValue}: ~"@{remValue}rem";    
}

But yet I think the syntax is good... at last I thought! Can you help me?

Thank you!

Upvotes: 1

Views: 133

Answers (1)

mheisig
mheisig

Reputation: 155

Are you using at least LESS 1.6? Variables as property names were added in 1.6. Prior to 1.6 there are some solutions but none are pretty.

Your snippet works in this LESS previewer which is running 1.6.0: less2css

Upvotes: 1

Related Questions