固定页脚打印不占整页宽度

时间:2015-11-05 20:46:17

标签: html css asp.net

我有一个隐藏的页脚,在打印页面时显示,但是当我尝试在chrome上打印时,它没有占据整页宽度。为什么呢?

我正在使用的代码

<style type="text/css">
   @media screen {
        div.divhead {
            display: none;
        }

        div.divFooter {
            display: none;
        }

    }
    @media print {
        div.divFooter {
            position: fixed;
            bottom: 0;
        }
    }
</style>
<div>
   <div>
      <div class="divhead">
         <asp:Image ID="Image1" ImageUrl="~/Images/head.jpg" Width="100%" runat="server" />
      </div>
   </div>
   <div class="content"></div>
   <div class="divFooter">
      <asp:Image ID="Image2" ImageUrl="~/Images/footer.jpg" Width="100%" runat="server" />
   </div>
</div>

2 个答案:

答案 0 :(得分:0)

使用固定位置和绝对位置时,需要指定宽度。

width: 100%添加到div.divFooter {}

答案 1 :(得分:0)

尝试添加此CSS

body, html{
   padding: 0;
   margin: 0;
}

 @media print {
        div.divFooter {
            position: absolute;
            min-width: 100%;
            bottom: 0;
        }
    }
相关问题