css - 在 safari 页面底部打印页脚

标签 css printing safari

我试图将一个 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/

相关文章:

internet-explorer - 过滤器 : progid:DXImageTransform. Microsoft.DropShadow(OffX ="x", OffY ="y", Color ="color") 是文本阴影 : in IE? 的可行替代品

html - 在导航栏中推开它的另一部分

c - 在 C 中打印 char 的二进制表示

python - 如何获取 python 中 eval 中打印的内容?

Javascript setinterval 函数在 MAC safari 上不起作用

html - 防止在 nowrap textarea 中将空格转换为不间断空格

css - 如何使用 <span> 缩进后续文本行

css - 有没有办法在 *.css 文件中执行特定于浏览器的条件 CSS?

javascript - javascript中取消打印功能后如何重新加载脚本?

html - 如何获取 div 动画的当前状态?