html – 在web应用程序的CSS上使用cm/mm来复制纸张交互是一个很好的做法?

前端之家收集整理的这篇文章主要介绍了html – 在web应用程序的CSS上使用cm/mm来复制纸张交互是一个很好的做法?前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我正在构建一个与文档交互的Web应用程序,以供以后打印。在某些方面与Google文档类似。我正在考虑在我的文档页面的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.

原文链接:https://www.f2er.com/html/233273.html

猜你在找的HTML相关文章