html - CSS 打印和@page 不工作

标签 html css printing

我有一个简单的 HTML 页面,我有

body, html {
  width: 100%;
  margin: 0;
  padding: 0;
}

@media print {
  @page {
    size: letter portrait;
    padding-left: 5in;
    padding-right: 0.25in;
    padding-top: 1in;
  }
}

但是,当我在 Chrome 中打印预览时,它似乎完全不受影响。我需要做什么才能让 Chrome 识别 @page 和媒体查询?

最佳答案

我认为您不需要媒体查询,因为@page 仅用于打印。

另外,根据:https://developer.mozilla.org/en-US/docs/Web/CSS/@page

You can only change the margins, orphans, widows, and page breaks of the document. Attempts to change any other CSS properties will be ignored.

也许使用边距代替填充会起作用。

关于html - CSS 打印和@page 不工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35236751/

相关文章:

html - 页面加载时的 CSS 不透明度

google-chrome - 在 chrome 的新标签页中打开打印预览页面

java - 如何在Java中打印二叉 TreeMap ?

javascript - 仅显示类名等于多个选中的复选框值 jQuery 的项目

html - 额外的普通功能区 css

html - 如何让我的页脚在 Stack Overflow 中停留在底部?

javascript - jQuery Accordion 菜单 : scroll to active menu item

html - ID 未对齐中心 CSS [outlook.com]

html - 表格中的特定行布局

html - 打印的网页看起来与实际页面有很大不同