html - 如何在没有正文重叠的情况下在每个页面上打印 HTML 页脚?

标签 html css

我试图让我的 HTML 页脚出现在每个打印页面上,而正文内容不会与页脚重叠。

我所拥有的基本上是这样的:

<style>
    footer {
        position: fixed;
        bottom: 5pt;
        height: 100pt;
    }
</style>
<div>
    content...
</div>
<footer>
    footer
</footer>

但是当正文内容太大时,它会与页脚重叠,我找不到解决方法。
我试过 @page { margin-bottom: 100pt; },但它也将页脚向上推,填充不起作用,position: running 什么也没做(我找不到是否有浏览器支持它)。

解决这个问题的必要条件是:

  • 页脚需要出现在打印的每一页上;
  • 页脚内容不能与页面的其余部分重叠;

最佳答案

footer {
        position: fixed;
        bottom: 5pt;
        height: 100pt;
        z-index:1000;
    }
<html>
  <head>
    <title> Page Title </title>
  </head>
  
  <body>
  
    <div>
        content...
    </div>
    <footer>
        footer
    </footer>
  </body>
  
</html>

使用 z-index给你的<footer>这样您的 body 部位就不会与页脚重叠。

希望这对您有所帮助。

关于html - 如何在没有正文重叠的情况下在每个页面上打印 HTML 页脚?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53342708/

相关文章:

html - 谷歌地图重叠到下面的 div 上

html - 表格在 Internet Explorer 中看起来很糟糕

javascript - onsubmit ="submitForm();"和 onsubmit ="return submitForm();"有什么区别

javascript - Bootstrap 切换菜单未关闭

javascript - polymer 模板有邮票事件吗?

javascript - 将 Bootstrap 模板与普通 Web 组件一起使用

html - 我的 HTML 按钮不工作

javascript - SVG位移贴图过滤器

html - 视差滚动内容样式

html - 标记 <a> 在相对定位的 block 上不可点击