位置:运行(标题)是CSS中无效的属性值,当使用WKHTMLTOPDF将HTML转换为PDF时

发布于 2025-02-13 14:02:56 字数 923 浏览 0 评论 0原文

我将一个可重复的标头和页脚设置为PDF文件。这是我的代码:

<style>
    @page { 
        size: A4 landscape; 
        margin: 0.5cm; 
         @top-center {content: element(footer)}
         @bottom-center {content: element(footer)}
    }
    .header { 
        position: running(header);
        width: 100%; 
    }
    .footer { 
        position: running(footer); 
        width: 100%; 
    }
</style>

<div class="header" id="headerContent" >
    It's header
</div>
<div class="footer" id="footerContent">
    It's footer
</div>
<main> 
Content
</main>

但是,当我在转换为PDF之前预览HTML代码时,似乎位置:running(header);不起作用。

我想我使用的版本不支持CSS中的此属性,但我不确定。

谁能帮我。 谢谢你!

I am setting a repeatable header and footer to the pdf file. Here is my code:

<style>
    @page { 
        size: A4 landscape; 
        margin: 0.5cm; 
         @top-center {content: element(footer)}
         @bottom-center {content: element(footer)}
    }
    .header { 
        position: running(header);
        width: 100%; 
    }
    .footer { 
        position: running(footer); 
        width: 100%; 
    }
</style>

<div class="header" id="headerContent" >
    It's header
</div>
<div class="footer" id="footerContent">
    It's footer
</div>
<main> 
Content
</main>

But when I preview the HTML code before converting to pdf, it seems that position: running(header); not working.
enter image description here

I guess that the version I used does not support this property in CSS, but I not sure.

Can anyone help me.
Thank you!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文