微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

html – css3页面媒体无法在任何浏览器中运行

您好我使用CSS3页面媒体模块http://www.w3.org/TR/css-gcpm-3/直接从浏览器打印HTML内容到PDF但我没有得到任何浏览器来处理它.我的工作如下.

Box-sizing: border-Box;
        -moz-Box-sizing: border-Box;
    }


        @page {
            size: letter;
            margin: 20mm 25mm;
        }
        @page {
            @top-center {
                content: element(pageHeader);
            }
        }

        @page  {
            @bottom-center {
                content: element(pageFooter);
            }
        }
        #pageHeader {
          position: running(pageHeader);
        }
        #pageFooter{
          position: running(pageFooter);
        }

    }
irst page.displayed in the examples above,or can be set for each side individually,as shown in the code snippet below,where the top and bottom margins are set to 2cm,and the left and right margins are set to 3cm:
The margins can be set as displayed in the examples above,and the left and right margins are set to 3cm:displayed in the examples above,and the left and right margins are set to 3cm:

displayed in the examples above,and the left and right margins are set to 3cm:

它对我来说在任何浏览器中都不起作用.我已经在最新的Chrome,FF,Opera,Safari中进行了测试.它应该在每个页面显示页眉和页脚.标题旨在显示在每个页面底部的每个页面和页脚的顶部.任何人都可以拥有实际工作的CSS3页面媒体模块元素的工作示例.此外,我不是寻找页眉和页脚的绝对或固定解决方案.我已经尝试了它,除了单页之外它不起作用.我缩短了这个问题的文本内容,但它可以复制和过去生成多页文档,以查看没有页眉和页脚的多个页面.页眉和页脚div保持在顶部.

最佳答案
它目前在任何最终用户浏览器中都不受支持,但PrinceXML支持它,这是一个用于生成PDF的专用引擎.见the CSS3 support for Margin boxes.

PrinceXML是一个商业产品,但我用它来从HTML源创建小说的印刷版本.它支持与打印相关的功能的完整列表. (我不以任何方式与他们联系.)

原文地址:https://www.jb51.cc/html/426075.html

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐