每个打印页面上的HTML设置页脚图像

时间:2011-04-25 11:30:42

标签: html css

我能够在每个打印页面上设置文本,但如果我必须设置图像来代替文本,我必须做出哪些必要的更改?这是我到目前为止使用的代码:

<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 个答案:

答案 0 :(得分:3)

尝试这样的事情:

@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>

有很多选择,这实际上取决于你想要完成什么。

答案 1 :(得分:0)

将以下内容放入CSS并根据您的要求设置widthheight,您也可以设置填充:

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