最后打印页面上的HTML页脚

最后打印页面上的HTML页脚

问题描述:

我想打印我的html页面。我有超过一页,并且仅在最后一页的底部打印页脚。我的CSS

I want to print my html page. I have more than 1 page and I want print my footer only at the bottom of the last page. My css

@page {
        size: 8.5in 11.0in;
        margin-left: 0.7cm;
        margin-top: 0.7cm;
        margin-top: 0.7cm;
        margin-bottom: 2.6cm;
        margin-right: 0.5cm
    }

#footer {
        clear: both;
        position: running(footer);
        z-index: 10;
        margin-top: -1em;
        vertical-align: bottom;
        height: 5%;
    }

 @page {
        @bottom-center {
            content: element(footer);
        }
    }

HTML:

<body><div id="content"></div>
       <div id="footer"></div>
<body>

它可以工作,但是当我的表最后很大时,例如6页表,我的页脚将填充所有带有表格的页面。

It works, but when I have very big table in the end my content, for example 6 pages table, my footer populates for all pages with table.

要使其更简单,您可以将页脚放置在媒体查询中

To make it more simple you could position the footer within a media query for printing another way:

@media print { 
body {
  position: relative;
  }
#printfooter {
  position: absolute;
  bottom: 0;
  }
}

作为快速变通建议。或者您使用带有@page扩展名的css3:

As a quick work-around suggestion. Or you use css3 with the @page extension:

@page:last {
    @bottom-center {
        content: element(footer);
    }
}

有关更多信息,w3有一个关于 CSS分页媒体模块。 5.3,示例7是您可以使用的信息!

For further information w3 has a pretty good documentary about CSS Paged Media Modules. 5.3, Example 7 is the information your good to go with!

希望其中一项有用!

最诚挚的问候,
玛丽安。

Best regards, Marian.