在Chrome中使用CSS打印目录的页码

Lea*_*yes 9 html css printing google-chrome

有没有办法打印目标页码与超链接,链接到同一文件中的各个地方?

<h1>Table of Contents</h1>
<ul>
    <li><a href="#introduction">Introduction</a></li>
</ul>

...

<section id="introduction"> <!-- Appears, for example, on page 3 when printed -->
    <h1>Introduction</h1>
    ...
</section>
Run Code Online (Sandbox Code Playgroud)

这样输出就像:

Table of Contents (page 0)

Introduction.........................3


...


Introduction (page 3)
Run Code Online (Sandbox Code Playgroud)

打印到PDF(在OS X上)时,我只需要将其与Google Chrome浏览器配合使用.

是否有一些CSS或JavaScript技巧可以让我实现这一目标?

Lea*_*yes 6

看起来这是 CSS 规范新工作草案的一部分:

http://www.w3.org/TR/2014/WD-css-gcpm-3-20140513/#cross-references

我怀疑是否有任何浏览器支持...

  • 您正在寻找类似 https://www.smashingmagazine.com/2015/01/designing-for-print-with-css/ 的内容 - 不幸的是,据我所知,目前只有 http://www.princexml。 com/ 支持这一点。 (2认同)