【问题标题】:Align footer to the bottom of printed HTML page?将页脚与打印的 HTML 页面的底部对齐?
【发布时间】:2013-03-01 15:18:18
【问题描述】:

我有一个标准网站,并且在打印时(用于在 Safari OS X 上制作 PDF),我希望页脚与它所在的任何打印页面的底部对齐 - 即文档的最后一页.

像这样:

这可能吗?


我已使用媒体查询 (@media print { }) 来获取所有其他打印样式表详细信息(为简单起见不包括在内)。

Demo code is here;对于screen 页面本身,这里是 HTML:

<div id="footer">
    <p>A bunch of example stuff inside here...</p>
</div>

绝对定位:

#footer {
    color: #fff;
    background: #000;
    width: 100%;
    position: absolute;
    bottom: 0px;
}

【问题讨论】:

标签: printing media-queries footer vertical-alignment sticky-footer


【解决方案1】:

有点旧,但答案肯定是使用 @page:last 选择器,但您还必须更改页脚的 CSS。

#footer { position: static; }

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

【讨论】:

  • 我不认为 @page:last 是一个存在的指令
猜你喜欢
  • 2019-05-27
  • 2011-04-01
  • 1970-01-01
  • 2013-07-03
  • 1970-01-01
  • 1970-01-01
  • 2021-06-09
  • 2011-04-26
相关资源
最近更新 更多