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
当我将前面的代码放入我的元素中时,我希望到处都能看到 1 厘米......
.myColumn{
width: 1cm;
}
W3C 表示对于低分辨率屏幕,大小写不一样。
为什么?
为什么他们不能正确生产1cm?
在手机、平板电脑和...中,唯一的屏幕单位是像素。
最佳答案
CSS units don't necessarily equate to exact dimensions .最后,屏幕上显示的每个 CSS 度量值最终都以像素为单位进行计算。
CSS 假定屏幕具有 96 dpi,因此使用 in、pt 和 pc 通常是安全的,尽管不同的显示器分辨率或用户定义的缩放可能会影响您的结果。
但公制单位是另一回事,因为没有精确的像素计算,因此浏览器会四舍五入以提供接近指定测量值的结果。这是 W3C only recommends px, %, or em units 的原因之一。针对屏幕的布局。
关于html - 为什么 CSS 中的绝对单位在不同的屏幕上显示的不是真正的绝对单位?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42046973/