css - 在 `cm` 中指定 CSS 大小不会产生正确的大小

标签 css

我有一个小型触摸屏显示器,我们正在为其提供 HTML 页面。 LCD 的物理尺寸为 4.624 厘米宽 x 3.508 厘米高。创建一个具有 widthheight 设置的 div 会在显示器上创建一个小得多的矩形。

为什么 cm 不能转换为屏幕上的实际尺寸?我需要进行哪些调整才能以厘米而不是像素为单位工作?

最佳答案

正如 w3c 文档所述:

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. On a laser printer, 1cm should be exactly 1 centimeter. But on low-resolution devices, such as computer screens, CSS doesn't require that. And indeed, the result tends to be different from one device to another and from one CSS implementation to another.

http://www.w3.org/Style/Examples/007/units.en.html#units

关于css - 在 `cm` 中指定 CSS 大小不会产生正确的大小,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31010541/

相关文章:

css - 系统地解决css中的样式冲突

javascript - 更改伪元素的样式::属性之后

HTML 标签或 CSS 属性

javascript - 如何创建一个搜索栏,用于下拉 SQL 数据库中的元素列表

jquery - 如何在文本字段附近创建一列按钮

html - 当我添加更多元素时悬停停止工作

css - 后台 float div

html - 如何在另一个网格上添加网格?

css - Webpack 4 : file-loader not loading assets in . css 或 .scss 文件

javascript - 似乎没有使用元素中传入的选项执行 Angular 指令