gpt4 book ai didi

html - 在复制纸张交互的 Web 应用程序的 CSS 上使用 cm/mm 是一个好习惯吗?

转载 作者:技术小花猫 更新时间:2023-10-29 11:47:55 27 4
gpt4 key购买 nike

我正在构建一个 Web 应用程序,该应用程序可以与文档进行交互以便稍后打印。在某些方面类似于 Google Docs。我正在考虑在我的文档页面的 CSS 上使用 cm/mm,因为它会帮助我生成文档。示例:

// A4 size
.page {
width: 210mm;
height: 297mm;
margin: 2cm 5cm;
}
<div class="page">
...
</div>

采用这种方法的主要问题是什么?

最佳答案

W3C 有一篇关于 CSS units 的精彩文章.特别是:

cm: Not recommended for screen / recommended for print

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 only place where you could use pt (or cm or in) for setting a font size is in style sheets for print, if you need to be sure the printed font is exactly a certain size. But even there using the default font size is usually better.

关于html - 在复制纸张交互的 Web 应用程序的 CSS 上使用 cm/mm 是一个好习惯吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16297619/

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