为什么 CSS 中的绝对单位在不同的屏幕上显示不是真正的绝对单位?
Why absolute units in CSS are not shown really absolute in different screens?
The so-called absolute units (cm, mm, in, pt and pc) mean the same in
CSS as everywhere else, but only if your output device has a high
enough resolution.
source: W3C
当我将前面的代码放入我的项目中时,我希望到处都能看到 1cm...
.myColumn{
width: 1cm;
}
W3C 表示对于低分辨率屏幕,大小写不一样。
为什么?
为什么他们不能正确生产1cm?
在手机、平板电脑和...中,唯一的屏幕单位是像素。
CSS units don't necessarily equate to exact dimensions。最后,屏幕上显示的每个 CSS 测量值最终都以像素为单位进行计算。
CSS 假定屏幕将具有 96 dpi,因此使用 in、pt 和 pc 通常是安全的,尽管不同的显示器分辨率或 user-defined 缩放可能会影响您的结果。
但公制单位是另一回事,因为没有精确的像素计算,因此浏览器会四舍五入以提供接近指定测量值的结果。这是 W3C only recommends px, %, or em units 用于屏幕目标布局的原因之一。
The so-called absolute units (cm, mm, in, pt and pc) mean the same in CSS as everywhere else, but only if your output device has a high enough resolution.
source: W3C
当我将前面的代码放入我的项目中时,我希望到处都能看到 1cm...
.myColumn{
width: 1cm;
}
W3C 表示对于低分辨率屏幕,大小写不一样。
为什么?
为什么他们不能正确生产1cm?
在手机、平板电脑和...中,唯一的屏幕单位是像素。
CSS units don't necessarily equate to exact dimensions。最后,屏幕上显示的每个 CSS 测量值最终都以像素为单位进行计算。
CSS 假定屏幕将具有 96 dpi,因此使用 in、pt 和 pc 通常是安全的,尽管不同的显示器分辨率或 user-defined 缩放可能会影响您的结果。
但公制单位是另一回事,因为没有精确的像素计算,因此浏览器会四舍五入以提供接近指定测量值的结果。这是 W3C only recommends px, %, or em units 用于屏幕目标布局的原因之一。