Closed ravenroc closed 7 years ago
It's not a bug. Value is always based on constant in configuration. font-size in rule can be overrided and you can't know this.
If it is not a bug, should I rewrite this as a feature request? The strength of using em
units is that they are sized relative to the set/inherited font-size
values. That's the core concept. Right now, as a workaround, I would be forced to use solely the rem()
function.
font-size in rule can be overrided and you can't know this.
Can you explain this a bit more? I'm not sure how postcss
cannot detect a new font-size
declaration in the CSS (which is how I'm interpreting the gist of this sentence).
Feature request won't be resolved because you don't know structure of your element. There's not relation between selectors in css.
There's not relation between selectors in css.
Yes, but couldn't you walk through each selector that has a font-size
rule attributed to it, create a mapping, and use the mapping to make em
calculations?
I've never developed a postcss plugin before, so excuse my ignorance as I try to understand how this is not feasible.
No, you can't now that h1 tag name and .heading class name is the same element.
The calculation for the
em()
function is based off of thesize
configuration option, rather than the inherited or setfont-size
value of the element. Theem()
function loses all purpose if it cannot account for the currentfont-size
value.Code
Within the config, the
size
option is set to the default16
. The following CSS is used:Expected Output
Actual Output