Kronuz / pyScss

pyScss, a Scss compiler for Python
MIT License
582 stars 141 forks source link

Adding px to em fails #303

Closed ThiefMaster closed 10 years ago

ThiefMaster commented 10 years ago

After updating from pyScss==1.1.5 to 1.2.0.post3, the following SCSS rule fails:

height: (6 * (1em + .5em)) + 1px;
ValueError: Can't reconcile units: <Number(9.0em)> and <Number(1.0px)>

Previously it evaluated just fine to height: 9.077em. Is it invalid SCSS or did I find a bug in pyScss?

ThiefMaster commented 10 years ago

OK, apparently it's invalid SCSS. How would I get the same result without hardcoding that value?

eevee commented 10 years ago

Convert one to the other using your font size.

height: (6 * (1em + .5em)) + 1px * 1em/12px;

Of course that's not very flexible — but pyscss 1.1.5 effectively hardcoded 12-pixels-per-em anyway, so this isn't any worse. :)

You could also use CSS3 calc() (though support is not great yet), or just move the extra pixel onto some other property.