cuth / postcss-pxtorem

Convert pixel units to rem (root em) units using PostCSS
MIT License
2.03k stars 174 forks source link

Consider blacklisting the HTML element? #24

Closed furzeface closed 8 years ago

furzeface commented 8 years ago

Hey,

We've encountered an issue with this task when we set our html element to have a base font-size (of 18px for example) - for the rest of the styles to inherit from.

The task runs on the html's CSS and converts its value to a rem unit based against the rootValue in the config (18), changing it to 1rem.

This then causes it to be 16px (browser default) and the other elements on the page that have been converted to rem units are sized relatively according to a 16px base size instead of the 18px that we want.

Is there a way to exclude the html root element - could that be a best practise going forward?

Or is there any advice you can give us if we are using this wrong? Currently we're ignoring the html element's CSS by putting px value in capitals as you suggest: html { font-size: 18PX;}.

Anything I can do to help let me know, thanks.

cuth commented 8 years ago

Does the selectorBlackList option solve your problem?

{
    selectorBlackList: [/^html$/]
}
JounQin commented 6 years ago

@cuth RegExp can not be used in package.json, anyway to achieve this?

cuth commented 6 years ago

@JounQin, yeah, that's a problem I didn't think about. Let's open an issue.