Home > Web Front-end > CSS Tutorial > Why Do Background Images Disappear When Printing in Firefox and Internet Explorer?

Why Do Background Images Disappear When Printing in Firefox and Internet Explorer?

DDD
Release: 2024-11-13 15:09:02
Original
672 people have browsed it

Why Do Background Images Disappear When Printing in Firefox and Internet Explorer?

How to Print Background Images in Firefox and Internet Explorer

Problem: Background images disappear when printing pages in Firefox or Internet Explorer, despite using them to represent information like stars indicating a level of skill.

Solution 1: Using a Print Stylesheet

Create a separate stylesheet specifically for printing:

/* print.css */

/* media:print */
.star {
    text-indent: 0;
}
Copy after login

Link the print stylesheet to your HTML document:

<link rel="print stylesheet" type="text/css" href="print.css">
Copy after login

Solution 2: Showing Image on Print

Add an image to represent your stars within the DIV element and hide it on screen:

/* media:screen */
.star img {
    visibility: hidden;
}

/* media:print */
.star img {
    visibility: visible;
}
Copy after login
<div class="star"><img src="./images/star.jpg" alt="*"></div>
Copy after login

The above is the detailed content of Why Do Background Images Disappear When Printing in Firefox and Internet Explorer?. For more information, please follow other related articles on the PHP Chinese website!

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template