我试图将一个 div(页脚)元素放在打印页面的底部。在 Firefox 中,这工作正常,div 将位于打印页面的底部。
但是,在 Safari 中,如果浏览器窗口不是很高,则页脚会在打印页面中上移。例如。如果浏览器窗口的高度为 200px,则页脚位于打印输出的下方约 200px。如果浏览器的高度为 400 像素,它会将页脚向下绘制 400 像素。
如果可能的话,我想在 Safari 中获得与在 Firefox 中相同的行为吗?
我为此使用的基本代码是:
<html>
<head>
<title>Print footer at bottom of a printed page</title>
<style type="text/css">
* { margin:0; padding:0; }
html, body { height: 100% !important; }
#footer { height:25px; border-top:solid 1px #000;
position:absolute; bottom:0; }
</style>
</head>
<body>
<p>Some content on the page here</p>
<div id="footer">This should appear at the very bottom of the printed page</div>
</body>
</html>
编辑:如果解决方案需要破解,我很高兴......它只需要在 Safari 中工作
最佳答案
我刚刚在 Chrome(与 Safari 相同的渲染引擎)中打印出来,底部显示了一行...
<!DOCTYPE html>
<html>
<head>
<title>Testing</title>
<style type="text/css" media="print">
html, body { margin: 0; padding: 0; }
body { height: 11in; width: 8.5in; }
#footer { position: absolute; bottom: 0; }
</style>
</head>
<body>
<div id="footer">
This will always print at the bottom
</div>
</body>
</html>
请注意,我在样式标签上有 media="print"
。有关更多信息,请阅读 Going to Print在 ALA 上。
关于css - 在 safari 页面底部打印页脚,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3760202/