CSS achieves different printing and Screen Display Results

Source: Internet
Author: User

In general web pages, we require that the printed results be the same as the displayed results, but in some reports or business systems, we may only need to print part of the page content. For example, if I only need to print data, however, buttons and backgrounds do not need to be printed, which is determined by business needs. We can imagine what would happen if a button appears in a printed invoice, it is estimated that it will pass out ~~

Now, let's talk about how to implement it. One way is to prepare a CSS file for screen display and printing, as shown below:

CSS for screen display:

<LINK rel = "stylesheet" href = "CSS/mainstylesheet.css" Media = "screen"/>

CSS used for printing:

<LINK rel = "stylesheet" href = "CSS/printstylesheet.css" Media = "print"/>

Note: These two CSS are placed in a Web page.

Another method is import:<Style type = "text/CSS">
@ Import URL ("CSS/printstylesheet.css") print;
</Style>

The last method is to directly write the screen display style and Print Style in a CSS file: @ Media Print {} {
H1 {
Color:Black;
}
H2 {} {
Color:Gray;
}
}

@ Media print content is only valid for printed content, and other content is the screen display style.

Related Article

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.