Why are the font sizes different

依然范特西╮ 提交于 2020-02-22 05:58:10

问题


I've got the following html and css
In Firefox the computed font size is 16.66667px
In Chrome the computed font size is 13px

Needless to say there is a good bit of difference in these two sizes, one is too small to read, one is nicely sized. I guess one way to work around it is to set the font size to 16.67px but why is this the case.

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN">
<html>
<head>
  <title>My first styled page</title>
  <style type="text/css">
    body {
        font-family: Arial, sans-serif;
        font-size: 10pt;
    }
  </style>
</head>
<body>

    This is some text.
</body>
</html>

All my measurements come from inspect element (using firebug in firefox).


回答1:


The font sizes are different because the browser programmers make different assumptions about the normal user's system.

There's nothing wrong with that, and this is also why you should not use px to set the font size. On a computer with a high-resolution screen, your font will be too small. Certainly 10px will be unreadable on many people's computers.

I recommend How to Size Text in CSS for a good overview of your choices.




回答2:


pt is a unit used for print and is not reliable for cross browser screen sizing. Try using another unit like px, em or a straight percentage.




回答3:


Try setting the font size in PX like font-size:10px



来源:https://stackoverflow.com/questions/3269986/why-are-the-font-sizes-different

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!