cuth / postcss-pxtorem

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

Set root font-size for html tag #10

Closed whdigger closed 8 years ago

whdigger commented 9 years ago

I set option it not the default

cuth commented 9 years ago

Okay, I see. You want a way to avoid changing the font size on the html element. Right now, there are two ways to accomplish this without changing the code.

The first is to use the new selector_black_list option and add html to that.

pxtorem({
   selector_black_list: ['html']
});

I know this is not ideal compared to your PR because everything in the html selector will be ignored. Plus any selectors including html will also be ignored. So I guess the first solution isn't perfect.

The next solution isn't in the README.md file yet but you can use an uppercase letter in the pixel unit decloration and it will get ignored.

html {
    font-size: 12Px;
}

That will still work in the browser and won't get replaced by pxtorem.

I'm thinking about adding your PR but tests need to be added.

cuth commented 9 years ago

Ah, just thought of something. You could probably target the html target better like this.

pxtorem({
   selector_black_list: ['^html$']
});

Or something similar, you might need to play with whitespace. The selector_black_list accepts regular expressions.

whdigger commented 9 years ago

ok, i try play with parameter selector_black_list