less / less.js

Less. The dynamic stylesheet language.
http://lesscss.org
Apache License 2.0
16.99k stars 3.41k forks source link

Less does not handle calculations within CSS variables #3793

Closed jacketwpbb closed 1 year ago

jacketwpbb commented 1 year ago

To reproduce:

@h: 1px;

:root {
  --a: @h * 10;
}

.a {
  height: @h * 10;
}

Current behavior:

:root {
  --asd-sss: 1px * 10;
}

.a {
  height: 10px;
}

Expected behavior:


:root {
  --asd-sss: 10px;
}

Environment information:

matthew-dean commented 1 year ago

This is as designed, although it probably isn't documented well-enough. Custom property values only do simple variable substitutions.

You have to do:

@h: 1px * 10;

:root {
  --a: @h;
}

.a {
  height: @h * 10;
}