html - 以像素为单位的 CSS 属性字体大小,它到底描述了什么?

标签 html css fonts typeface

CSS 属性 font-size 可以定义其“长度”(以像素为单位)。

它具体描述了什么,它是标称字符(例如,'m')的宽度(或高度),它是字体文件描述中的某个属性,还是其他东西?

我一直无法找到这条信息:我在一些接受的答案(在 stackoverflow 中)中发现的是大写字母“H”的高度,其他大写字母“I”和较低的“p”加上一些金额。

如果能提供指向实际规范的链接,我将不胜感激。顺便说一句,http://www.w3.org/TR/CSS2/fonts.html#font-size-props似乎对这方面保持沉默。

我很想知道这个指标与等宽字体字符宽度的关系。

最佳答案

CSS 3 specification更清晰:

This property indicates the desired height of glyphs from the font. For scalable fonts, the font-size is a scale factor applied to the EM unit of the font. (Note that certain glyphs may bleed outside their EM box.) For non-scalable fonts, the font-size is converted into absolute units and matched against the declared font-size of the font, using the same absolute coordinate space for both of the matched values.

你问:

what I have found, in some accepted answers (in stackoverflow), statements being the height of capital 'H' otherss of capital 'I' and lower 'p' plus some amount.

这取决于字体。 CSS 只能描述 em 框的所需高度,但字体作者可以在其内部或外部任意位置绘制字形。参见 here了解更多详情。

I am interested in that to know how this metrics relate to monospace typeface's character width.

只是间接的。不同的等宽字体有不同的高度和宽度比例。

关于html - 以像素为单位的 CSS 属性字体大小,它到底描述了什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20799277/

相关文章:

javascript - 如何区分文件或文件夹在被拖放之前是否被拖动?

jquery - 如何使用另一个在线mp3资源更改<audio>标签中的src attr并重新加载它

css - 防止网络移动浏览器上的 x 滚动

html - 同一站点上不同页面的站点标题显示不同

python - Pygame:字体模块不可用

android - 如何在 android 中通过 javascript 更改 WebView 内容字体系列?

php - 如何获取数据库中的数据并在View中显示具体数据(Codeigniter)

html - 如何在文章的引导列中使用 nth-child()

html - Bootstrap 网格环绕少于 12 列

javascript - 有什么办法可以更改此处显示的任何文件以通过webpack进行部署?