font-size:62.5% vs. font-size:10px

前端 未结 2 1972
南方客
南方客 2020-12-13 19:52

For a long time I\'ve been using

body {font-size:62.5%;}

in CSS documents since it\'s supposed to

相关标签:
2条回答
  • 2020-12-13 20:14

    You're going to get arguments for both sides of this issue. I'm guessing a majority are going to argue for %. But you asked for drawbacks or pitfalls

    The main drawback you would encounter would be if you ran across a browser or device that honored your pixel setting instead of a percentage of whatever it's default is, and that pixel setting happened to be problematic or too small to read. If that browser didn't offer the user an opportunity to either scale the font or zoom in on the page, then you could have a potential problem.

    All that said, almost every browser these days has that default set at 16px. I can't speak to why IE in your case is sizing it differently. If you are going for a pixel perfectly sized design, then use px, otherwise I'd suggest staying with the %.

    0 讨论(0)
  • 2020-12-13 20:36

    You could just use:

    html {font-size:10px}
    

    So know you can work just with rem or em without complex calculations: 1 rem = 10px 2 rem = 20px

    0 讨论(0)
提交回复
热议问题