font-size的默认单位? [英] Default unit for font-size?

查看:840
本文介绍了font-size的默认单位?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

网络上的各种文本声称pt是没有提供时的默认字体大小单位,然而,我自己的测试似乎证明了其他。我已经阅读了很多关于W3C的文档,涉及CSS 1-3的字体大小,我似乎找不到任何规范中默认单位的实际引用。

Various texts on the net claim that "pt" is the default font-size unit when none is provided, however, my own testing seems to demonstrate otherwise. I have read many documents on W3C covering font-size for CSS 1-3, and I can't seem to locate an actual reference to a default unit in any of the specifications.

我已经测试了这一点在Chrome和IE9,并得到完全相同的结果与每个:缺少一个单位的元素是最小的,px元素在中间,并且pt元素是最大的。我尝试使用W3C定义的许多其他单位(例如mm,ex,pc等)匹配大小,但是 none

I have tested this in both Chrome and IE9 and get the exact same results with each: the element lacking a unit is the smallest, the px element is in the middle, and the pt element is the largest. I attempted to match the size using many other units defined by the W3C (such as "mm", "ex", "pc", etc.) but none of the test elements match up in size to the targeted element (the one lacking units).

Any insight would be appreciated.

code>< div style =font-size:20;> 20 size< / div>
< div style =font-size:20px;> 20px size< / div>
< div style =font-size:20pt;> 20pt size< / div>

<div style="font-size: 20;">20 size</div> <div style="font-size: 20px;">20px size</div> <div style="font-size: 20pt;">20pt size</div>


推荐答案

a font-size 使用无单位数无效,因此被忽略。你可能会发现文字大小实际上是 14px (取决于浏览器的默认值)。

a font-size that uses a unitless number is invalid and therefor ignored. You'll probably find the text size is actually about 14px (depending on the browser's defaults).

这篇关于font-size的默认单位?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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