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: ....; 
} 
相關問題