CSS 打印样式表生成的内容未显示

CSS print stylesheet generated content not showing up

我遇到了一个奇怪的问题,即通过 CSS 为打印样式表生成的内容不会显示。打印样式表应用于打印,但生成的内容并没有显示出来。

一个例子:

<!DOCTYPE html>
<html>
<head>
<title>Testprint</title>
<style>

    @media print {
        @page {
            size: auto;
            margin: 2cm;
            @top-center { 
                content: 'dsdsdfsdfdfs';
                font-size: 10pt;
                text-align: center;
                color: black;
            }
        }
        h1 {
            color: red;
        }
    }

</style>
</head>
<body>
    <h1>PRINT</h1>
</body>
</html>

h1 的红色应用于打印,但@top-center 选择器的内容未显示。非常感谢有关如何解决此问题的任何指示。

这是 CSS Generated Content for Paged Media (affectionately known as GCPM) module. There are no known stable implementations of GCPM in mainstream browsers at this time, though there is some coverage of the related CSS Paged Media 3 模块的一个功能。