css html 页脚
我正在重写这个问题以更好地传达问题:
我有 3 种输出机制:
- 屏幕
- 打印
PDF 是使用与屏幕相同的媒体类型生成的。
在屏幕上:我只想页脚出现在内容下方...简单...简单!
PDF:我希望页脚显示在内容最后一页的底部
打印:如上所述,我希望页脚显示在内容最后一页的底部
问题是:如果我为媒体设置绝对定位type=print 有两个问题:
- 这对 PDF 显示没有影响
- 如果内容跨越多个页面,则内容打印在固定在第一页底部的页脚下。
如果在屏幕上 - 我需要页脚显示在假想页面的底部,以便生成 pdf 时,它会显示在最后一页内容的底部
如果在打印上 - 我需要页脚显示在最后一页内容的底部内容页
I am re-writing this question to better convey the problem:
I have 3 output mechanisms:
- Screen
PDF's are generated using the same media type as screen.
On screen: I just want the footer to appear below the content ... Simple... easy!
PDF: I want the footer to display at the bottom of the last page of the content
Print: As above, I want the footer to display at the bottom of the last page of the content
The problem is: If I set absolute positioning for media type=print there are two problems:
- This has no effect of the PDF display
- If the content spans over multiple pages, the content prints under the footer which is fixed at the bottom of the first page.
If on screen - I need footer to display at the bottom of an imaginary page so that when the pdf is generated, it appears at the bottom of the last page of content
If on print - I need footer to display at the bottom of the last page of content
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
您可以为页面定义 2 个样式表; 1 代表“屏幕”,1 代表“打印”。以这种方式链接到它们:
这样您就可以完全分离每个设备应如何呈现您的页面。
You can define 2 stylesheets for the page; 1 for "screen" and 1 for "print". Link to them this way:
This way you have total separation of how each device should render your page.
您绝对应该查看 http://www.cssstickyfooter.com/。这是一个优秀的、现代的“粘性页脚”解决方案。至少,它应该有助于引导您走向正确的方向。
You should definitely check out http://www.cssstickyfooter.com/. It's an excellent, modern "sticky footer" solution. At a minimum, it should help lead you in the right direction.
您可以通过为打印文档提供单独的 CSS 样式表来实现此目的。 CSS 媒体类型允许您为打印文档(以及许多其他表示形式)指定单独的规则。
如果这是唯一需要特殊处理的样式,那么您可以将打印样式放入现有样式表中,如下所示:
如果您有很多特定于打印的规则,请将它们放入单独的样式表中,并将两个样式表都包含在 HTML 中,如下所示:
当显示在屏幕上时,仅使用 all.css 样式表;打印时,将使用 all.css 和 printonly.css 样式表 - 因此您不需要在两个文件中复制样式,只需添加特定于打印机的样式到printonly.css。
有用的参考:
http://www.w3.org/ TR/CSS21/media.html
You can achieve this by having a separate CSS stylesheet for printed documents. CSS Media Types allow you specify separate rules for printed documents (and many other representations).
If this is the only style that needs special handling then you can put the print style in your existing stylesheet like this:
If you have a lot of print-specific rules, put them in a separate stylesheet and include both stylesheets in your HTML like this:
When displayed on the screen only the all.css stylesheet will be used; when printed both the all.css and the printonly.css stylesheet will be used — so you don't need to duplicate your styles in both files, just add printer-specific ones to printonly.css.
Useful reference:
http://www.w3.org/TR/CSS21/media.html
我认为您可能正在寻找的是 CSS 粘性页脚最终您的页脚需要在你的包装器
页面
CSS
之外
直接从cssstickyfooter网站获取。在OP编辑他的答案以解释他正在寻找打印之前我发布了我的答案。
I think what you might be looking for is the CSS Sticky FooterUltimately your footer needs to be outside of your wrapper
Page
CSS
Taken directly from the cssstickyfooter website.I posted my answer before the OP edited his answer to explain that he was looking for print.