css – Google Chrome打印分页符

前端之家收集整理的这篇文章主要介绍了css – Google Chrome打印分页符前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我试图让google chrome做分页符。

我被一群网站告诉page-break-after:always;在chrome是有效的,但我似乎不能得到它工作,即使一个非常简单的例子。有什么办法在Chrome中打印时强制分页

解决方法

我已在所有主要浏览器(包括Chrome)中成功使用以下方法
<!DOCTYPE html>

<html>
  <head>
    <Meta http-equiv="content-type" content="text/html;charset=UTF-8" />
    <title>Paginated HTML</title>
    <style type="text/css" media="print">
      div.page
      {
        page-break-after: always;
        page-break-inside: avoid;
      }
    </style>
  </head>
  <body>
    <div class="page">
      <h1>This is Page 1</h1>
    </div>
    <div class="page">
      <h1>This is Page 2</h1>
    </div>
    <div class="page">
      <h1>This is Page 3</h1>
    </div>
  </body>
</html>

这是一个简化的例子。在实际代码中,每个页面div包含更多的元素。

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

猜你在找的CSS相关文章