css - 1pt有多大?

标签 css dpi ppi

我真的需要知道这个。每个人(希望如此)都知道 dpi 在网络上无关紧要,无论您使用 4000 还是 1 dpi 保存和成像都没有关系,您的计算机只是显示它指向像素。 现在,pt 中的 css 和字体大小如何?许多网站说 windows 使用 96 dpi 而 mac 72 这意味着 1 pt 在 mac 上是 1 px 而在 windows 上是 1,333 px。 但这没有意义,操作系统与任何分辨率无关,只有屏幕有 PPI,没有 dpi。 ppi取决于屏幕。

1pt 在 mac 上是 1px,在 pc 上是 1,333px 是真的吗?

最佳答案

This is quite a good read on the subject

Points (pt): Points are traditionally used in print media (anything that is to be printed on paper, etc.). One point is equal to 1/72 of an inch. Points are much like pixels, in that they are fixed-size units and cannot scale in size.

See this article from W3C

The so-called absolute units (cm, mm, in, pt and pc) mean the same in CSS as everywhere else. A length expressed in any of these will appear as exactly that size (within the precision of the hardware and software). They are not recommended for use on screen, because screen sizes vary so much. A big screen may be 60cm (24in), a small, portable screen is maybe only 8cm. And you don't look at them from the same distance.

The relation between the absolute units is as follows: 1in = 2.54cm = 25.4mm = 72pt = 6pc

因此,在 72 PPI(每英寸像素)显示器上,1 像素 = 1 点,因此在 Mac 上如果 PPI 为 72,则 1pt = 1px,在 Windows 机器上如果 PPI 为 96,则 1pt = 1.3 'px.

The 72 for mac and 96 for Windows are only defaults但是,可能会因可用的硬件和系统设置而异。

Points are for print? Nope.

Points are not for print exclusively. Theoretically, points are for defining an absolute measure. Pixels are not absolute, since depending on your screen and chosen definition (not resolution), the resolution (pixels per inch) can go from a lot (150dpi) or very little (75dpi). Which means your pixels can be a size, or maybe half that size. Which means that text you design to be perfectly legible on your screen may look too big on your client’s screen (“please make the text smaller, ok?”) or too small to be readable on your neighbor’s screen (“hey, the website you told me about the other day? the one you said you had worked on… well i couldn’t read the text very well, it’s so small”).

Points are a solution to this issue. But browsers and operating systems need to manage those. Basically, it means:

browsers have to calculate the display size in pixels using the given value (say, 10pt) and the screen’s real resolution; operating systems have to communicate the real current resolution, and not a default value.

此外,take a look at this question , and this article

关于css - 1pt有多大?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22477561/

相关文章:

ios - 在 iOS 中绘制标尺 - 在屏幕上精确 1 厘米 - 如何绘制相距 1 毫米的线?

perl - PPI::Document 错误或一些特殊的子程序名称?

html - 设置 <hr/> 标签的样式以显示为 appx 默认粗细(如果能够设置 <div> 的样式以获得好的结果!)

php - 使用 PHP 获取实际宽度而不是自动宽度

CSS float :left usage

css - Angular (12) 重复我的全局 css 变量

windows - 是否有一种简单的方法可以强制Windows使用固定的DPI值而不是当前DPI设置来计算文本范围?

delphi - Delphi Seattle 中运行时 DPI 更改后如何处理菜单缩放

c++ - 设置高 DPI 时防止我的 Win32 应用程序的 UI 元素被放大

perl - 如何找到带有 PPI 的注释,然后在它之前插入代码?