CSS字体大小 [英] CSS Font Size Specifics
问题描述
我对字体大小有几个具体问题:
I have a couple of specific questions about font size:
- pt(I.E. 12pt)是否标准化?我想我读的地方pt = 1/72英寸。但是,photoshop中的24pt字体的大小与css中的24pt字体大小有很大不同。
- 字体大小究竟是什么?这是一种关于字母大小的非标准任意描述,还是实际上是指字母的具体高度或宽度属性?
谢谢Stack!
推荐答案
font-size是字体的基本高度(大写字母H的高度)
font-size is the baseline height of the font (the height of a capital H character) plus a little room above it (the ascender) and larger amount of room below it (the descender).
对于特定字体大小的特定字体,基线高度将始终为相同大小。以下是一些基于Arial字体测量的示例:
For a particular font at a particular font-size, the baseline height will always be the same size. Below are some examples, based on measurements of the Arial font:
font-size baseline height
10 7
11 8
12 9
14 10
,pt是px中基线高度的粗略近似。例如,font-size:9pt的基线高度为9px,对应于font-size:12px。在实践中,我有时发现pt比基线高度大0.5到1.0像素。
In theory, for CSS, pt is a rough approximation of the baseline height in px. For instance, a font-size:9pt has a baseline height of 9px, which corresponds to font-size:12px. In practice, I've sometimes found that pt is larger than the baseline height by 0.5 to 1.0 px.
这是一个 jsfiddle 显示了px和pt中资本H的并行比较。
Here's a jsfiddle showing a side-by-side comparison of capital H's in px and pt.
在大多数PSD中,看到,指定为12pt的字体实际上是12px。但这可能会有所不同。当有疑问时,测量文本的基线高度,并从中向后转换为px中的字体大小。例如,如果大写H的高度为9px,则font-size为12px。有时,PSD中的抗锯齿使得难以准确测量基线高度。
In most PSDs I've seen, a font specified as 12pt is in fact 12px. But this may vary. When in doubt, measure the baseline height of the text and convert backwards from that to a font-size in px. For instance, if a capital H has a height of 9px, then the font-size is 12px. Sometimes antialiasing in a PSD makes it difficult to accurately measure the baseline height.
这篇关于CSS字体大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!