简体   繁体   English

打印带有背景图像的 HTML 页面时未显示文本

[英]Text is not showing when I print my HTML page with a background image

I am printing an HTML image that has a background url with some formatted text on the it.我正在打印一个 HTML 图像,它有一个背景 url,上面有一些格式化的文本。 However, I noticed that when I click on print preview, it only shows the background image without the text that are dynamically placed on it.但是,我注意到当我单击打印预览时,它只显示背景图像,而没有动态放置在其上的文本。

<div class="certificado_pagina">
        <div class="certificado_conteudo">
            <!-- dynamic content goes here -->
        </div>
    </div>

This class selector (certificado_pagina) inherit the background image url.这个类选择器(certificado_pagina)继承了背景图片的url。

I have add the css below to the body tag but still not showing the text on the background image我已经将下面的 css 添加到 body 标签中,但仍然没有在背景图像上显示文本

@media print {
    body {
        content: url(../images/certificate.png);
        color: #000;
    }
}

Please help.请帮忙。 Thanks谢谢

If you want the entire page ro have background image, you have to specify background image on the body element like so:如果您希望整个页面 ro 具有背景图像,则必须在body元素上指定背景图像,如下所示:

<style>
body {
    background-image: url(...);
}
</style>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM