CSS 仅在最后一页打印页脚 [英] CSS Print page footer only on last page

查看:61
本文介绍了CSS 仅在最后一页打印页脚的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

首先,我搜索了SO,但没有可行的解决方案

First of all, I've searched SO and there is no working solution

我有一些很长的内容,我只想在最后一页有页脚.我累了:

I have some long content, and I want to have footer only on last page. I tired:

1)

.footer{       
    position: absolute;
    bottom: 0;
}

如果只将页脚放在第一页的末尾.

If puts footer at the end of first page only.

2) 正如旧答案所暗示的

2) As old answers suggest

@page :last

但是 :last 不存在(正如我从旧答案中看到的那样).

But :last doesn't exist (as I see from old answer it existed).

3) 正常页脚,确保它显示在所有页面的末尾.

3) Normal footer, sure it is shown on the end of all pages.

我怎样才能做到这一点,页脚只在最后一页?

How can I achieve this, footer only on last page ?

推荐答案

您可以尝试将 header 和 body 的主要区域包装在其自己的容器中,然后为其赋予 100vh 的 min-height 属性.这应该将页脚推到最底部,因为页眉和主要部分总是占据主视口.

You can try wrapping your header and main area of body in its own container and then giving it a min-height property of 100vh. This should push your footer to the very bottom as the the header and main sections always takes up the main viewport.

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

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