加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 资源网站 > 资源 > 正文

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

发布时间:2020-12-14 21:45:48 所属栏目:资源 来源:网络整理
导读:我正在构建一个与文档交互的Web应用程序,以供以后打
我正在构建一个与文档交互的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.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读