最后打印页面上的HTML页脚 [英] HTML footer at the last printed page

查看:119
本文介绍了最后打印页面上的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有一个关于< a href = http://www.w3.org/TR/css3-page/ rel = nofollow> 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.

这篇关于最后打印页面上的HTML页脚的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆