Yosef Waysman
Yosef Waysman

Reputation: 123

How to refer to properties values as variables in LESS?

Is there a way to use property names as variables in LESS?

For example:

h1 {
  font-size: 16px;
  line-height: font-size * 2;
 }

The above snippet doesn't work, and I wonder how to get this effect?

Upvotes: 1

Views: 89

Answers (1)

vicente
vicente

Reputation: 2633

I don't think it's possible.

A workaround is creating a variable and assign the font-size to it. Then you can use this to multiply the value:

@fontsize: 16px;

h1 {
    font-size: @fontsize;
    line-height: @fontsize * 2;
}

Upvotes: 2

Related Questions