Less.js: css calc( {percentage} -/+ {pixel amount} ) outputs as calc({percentage - pixel amount as percentage})

Created on 5 Feb 2015  ·  2Comments  ·  Source: less/less.js

example:

less:

a {

  left : calc(50% - 40px);
  width: 40px;
}

gets compiled as:

css

a {
  left: calc(50% - 40%);
  width: 40px;

}

/* or */

a {
  left: 10%;
  width: 40px;
}

What do?

Most helpful comment

Is Strict Math enabled when you build? http://lesscss.org/usage/#command-line-usage-strict-math

You could try escaping the value:

a {
  left: calc(~"50% - 40px");
  width: 40px;
}

All 2 comments

Is Strict Math enabled when you build? http://lesscss.org/usage/#command-line-usage-strict-math

You could try escaping the value:

a {
  left: calc(~"50% - 40px");
  width: 40px;
}

Yes: --strict-math.
Closing as duplicate of #974.

Was this page helpful?
0 / 5 - 0 ratings