为什么字体大小不同 [英] Why are the font sizes different

查看:140
本文介绍了为什么字体大小不同的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有以下html和css
在Firefox中,计算出的字体大小为16.66667px
在Chrome中,计算出的字体大小为13px

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

不用说这两种尺寸之间有很大的差异,一种尺寸太小而无法阅读,一种尺寸很好.我猜想解决该问题的一种方法是将字体大小设置为16.67px,但为什么是这种情况.

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>

我所有的测量值都来自检查元素(在firefox中使用firebug).

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

推荐答案

字体大小不同,因为浏览器程序员对普通用户的系统做出了不同的假设.

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

这没什么不对,这也是为什么您不应该使用px设置字体大小的原因.在具有高分辨率屏幕的计算机上,您的字体将太小.当然,在很多人的计算机上10px都是不可读的.

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.

我建议您如何在CSS中调整文本大小,以更好地了解您的选择.

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

这篇关于为什么字体大小不同的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆