打印CSS - 元素的完整页面

JP.*_*JP. 16 css printing

我的media="print"CSS中是否有一些语法可以使一个div元素覆盖整个打印页面?

<div id="important_thing">Important!</div>
<ol id="other_stuff">
  <li>Thing</li>
  <li>blah</li>
</ol>
Run Code Online (Sandbox Code Playgroud)

print.css

#important_thing {
  width:100%;
  height:100%;
}

#other_stuff li {
  float:left;
  width:20pt;
  height:8pt;
}
Run Code Online (Sandbox Code Playgroud)

这没有达到预期的效果.我希望有一个完整的页面用于"重要的东西"以及所有列表元素所需的许多其他页面.

有任何想法吗?

Tra*_*mer 21

Use a page-break-after

http://www.w3schools.com/cssref/pr_print_pageba.asp

#important_thing { 
  width:100%; 
  height:100%;
  page-break-after:always 
}
Run Code Online (Sandbox Code Playgroud)

You may have to combine it with a page-break-before:always

  • 宽度:100vw; 身高:100vh; (3认同)
  • 这会在元素后面插入分页符,但它*不会*使元素覆盖整个页面。元素的大小保持不变,可以通过例如对其应用背景颜色来检查。 (2认同)

phi*_*294 5

正如明天__所指出的,这可以通过应用来实现

width: 100vw; height: 100vh;
Run Code Online (Sandbox Code Playgroud)

到元素。