gpt4 book ai didi

html - CSS 像素真的是一个绝对单位吗?也就是说,1 inch = 96px 是真的吗?

转载 作者:技术小花猫 更新时间:2023-10-29 12:02:04 26 4
gpt4 key购买 nike

官方W3C documentation说:

1 px = 1/96th of 1 in

在我之前的 18.5 英寸屏幕中,screen.width1367 px 并且以英寸为单位的屏幕宽度是 14 英寸。通过 W3C 公式:

14 * 96 px = 1344 px

W3C 公式偏离了 每英寸 20/14 像素。由于偏差太小,而我屏幕上的1 inch97.4 px 我接受了W3C的公式,认为一个CSS像素是的绝对单位measure,这意味着它始终等于 0.75 pt(一个物理单位)。

这周我买了一个 21.5 英寸的全高清屏幕,宽度为 19 英寸screen.width1920 px。所以现在我屏幕上的 1 英寸 是:

1920/19 ~ 101 px

不仅如此,我 friend 的屏幕是 24 英寸,并且具有相同的 1920 x 1080 分辨率。 24 英寸和 21.5 英寸不能对应相同数量的 CSS 像素。

所以现在,在我的屏幕上,CSS 像素不是绝对的度量单位。而且我屏幕上的所有内容都相对较小。即便如此,现在我也被我的字体大小迷惑了。当我在屏幕上发现 16 px 作为最小可读字体时,它实际上在较小的屏幕上更大。因为我屏幕上的 16 px 在物理上与我以前较小屏幕上的 14px 相同(以厘米为单位)。我的网站设计有误,我不再是一名优秀的前端开发人员。

所以问题:

  • CSS 像素真的是一个绝对单位吗?也就是说,1 英寸 = 96 像素是否正确?

最佳答案

正如在 CSS Values and Units Module 的部分稍微往下指定的那样你已经链接了,有两种不同的实现可以应用 CSS:

For a CSS device, these dimensions are anchored either

i. by relating the physical units to their physical measurements, or
ii. by relating the pixel unit to the reference pixel.

这继续说明:

If the anchor unit is the pixel unit, the physical units might not match their physical measurements. Alternatively if the anchor unit is a physical unit, the pixel unit might not map to a whole number of device pixels.

最后总结一下:

The reference pixel is the visual angle of one pixel on a device with a pixel density of 96dpi and a distance from the reader of an arm’s length. For a nominal arm’s length of 28 inches, the visual angle is therefore about 0.0213 degrees. For reading at arm’s length, 1px thus corresponds to about 0.26 mm (1/96 inch).

这意味着像素单元一个绝对长度,但它的长度可以根据设备应用i实现还是ii实现而改变> 来 self 在这里引用的第一部分。

绝对 长度,由 CSS 值和单位模块定义,只是一个“锚定到某些物理测量值”的长度。物理测量将是它们的实际物理长度或由引用像素导出的长度。

规范的同一部分还说:

For print media and similar high-resolution devices, the anchor unit should be one of the standard physical units (inches, centimeters, etc). For lower-resolution devices, and devices with unusual viewing distances, it is recommended instead that the anchor unit be the pixel unit. For such devices it is recommended that the pixel unit refer to the whole number of device pixels that best approximates the reference pixel.

96px 并不总是等于 1 现实生活中的英寸。

关于html - CSS 像素真的是一个绝对单位吗?也就是说,1 inch = 96px 是真的吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40480617/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com