【问题标题】:how to add footer on bottom of the last printed page如何在最后打印的页面底部添加页脚
【发布时间】:2023-03-24 18:28:01
【问题描述】:

我正在创建一个基于网络的计费系统,我必须在其中生成多个页面的账单 pdf。

问题是:我想在最后一个打印页的底部打印页脚。

#footer{
  position: fixed;
  bottom: 0px;
  width:100%;
}

此代码在每一页上打印页脚,但我只希望在最后一页上。

【问题讨论】:

  • 只在最后一页保留页脚。意味着,隐藏其他页面的页脚并通过 CSS 将其显示在最后一页。
  • 尝试position: absolute 并检查:stackoverflow.com/questions/1176770/…
  • pdf 是由浏览器使用打印样式表生成的,我怎么知道哪一个是最后一页? @阿努
  • 我试过 positon:absolute,但它给出了相同的结果@Bellian
  • 那么也请检查链接。

标签: css html pdf printing


【解决方案1】:

将类添加到最后一页,例如.last_page

然后我想:

.last_page #footer {
  position: fixed;
  bottom: 0px;
  width: 100%;
}

【讨论】:

  • pdf是浏览器使用打印样式表生成的,我怎么知道哪个是最后一页?
  • 我认为根据内容,您可以将 DOM 元素页脚添加到 html 内容的末尾
  • 实际上我正在使用 angualrjs 在 DOM 中动态添加购买的产品列表,但页眉和页脚是静态的,所以它们已经在那里,或者我认为我没有得到你的观点
  • Harshit 你说它“动态添加列表”,在列表的末尾插入你的 DOM 元素我认为很容易知道你的列表数组中的最终循环......
  • @andrewsaeed 向页面添加类没有帮助,OP 不知道哪个页面是最后一个页面。如果是他,他会自己添加页脚。
【解决方案2】:

将此添加到您的样式表中,看看它是否对您有帮助:

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

参考:html footer at last page

【讨论】:

  • 我试过了,还是不行。当我添加这个 css 时,页脚将开始与最后一个打印页面上的内容重叠
猜你喜欢
  • 1970-01-01
  • 2016-01-31
  • 2018-10-23
  • 2013-11-18
  • 1970-01-01
  • 2015-05-11
  • 2015-02-11
  • 1970-01-01
  • 2021-06-09
相关资源
最近更新 更多