2011-04-25 121 views
0

我可以在每个打印页面上设置文本,但是如果必须设置图像而不是文本,我必须进行哪些必要的更改?这里是我到目前为止所使用的代码:在每个打印页面上设置HTML页脚图像

<div class="divFooter">UNCLASSIFIED</div> 

CSS:

<style type="text/css"> 
    @media screen { 
     div.divFooter { 
      display: none; 
     } 
    } 
    @media print { 
     div.divFooter { 
      position: fixed; 
      bottom: 0; 
     } 
    } 
</style> 

预先感谢您。

回答

2

尝试是这样的:

@media print { 
    div.divFooter { 
     position: fixed; 
     background: url(http://path/to/image.png); 
     height: 100px; /* put the image height here */ 
     width: 100px; /* put the image width here */ 
     bottom: 0; 
    } 
} 

当然,你也可以做这样的事情,而不而是采用任何额外的CSS:

<div class="divFooter"><img src="..." /></div> 

有很多的选择,它真的取决于你想要完成什么。在你的CSS以下和

+0

感谢名单jon..but。我必须在每个页面上放置页面......类似于1/5,2/5 ...等等。其中5是页面的全部否。如何做到这一点? – Denish 2011-04-26 05:57:41

+0

请注意,添加背景图片很愚蠢:浏览器默认禁用背景图片(用户需要在浏览器的首选项中手动打开背景图片)。因此,如果您想在“只打印重复”页脚内显示图像 – 2013-02-21 15:51:17

+0

,您是否可以使用第二种解决方案​​?这只会出现在第一页上。 – David 2015-07-06 16:16:46

0

的Place根据您的要求widthheight,你也可以设置填充:在“页脚形象标志”

.divFooter { 
    background:url(imagepath); 
    float: left or center; // according to ur requirement 
    width: ... ; 
    height: ....; 
}