Using CSS to print the display background

Source: Internet
Author: User

The previous article has described how to implement the printing function on the browser side. Later, there is a problem, that is, the table header has a background color, but the actual print out no background color. The methods of online mainly have the following ways of realization:

1. Write the background color into the inline style, as shown in:

But found that this is written, and not. may also need to set up other, if have to know the pro, hope to enlighten ~

2. When printing, the user set themselves, such as:

Although this approach works, it is not realistic to consider the user experience.

3. Directly with CSS control, this method is effective, simple ~ directly on the code:

@media Print {
. receipt-print. Table th {
Background-color: #f1f4f7!important;
-webkit-print-color-adjust:exact;
}
}

@media Print is for printing media.

The-webkit-print-color-adjust property is not a standard attribute, meaning that the use method can be accessed https://developer.mozilla.org/en-us/docs/web/css/- Webkit-print-color-adjust.

Using CSS to print the display background

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.