Media & quot; print & quot; css is used to control the file to be printed. media is the print Style, indicating that the style takes effect only when printing. The following is a detailed introduction, do not miss out. use the CSS of media = "print" to control the file testprint.html to reference the print Style of media, indicating that this style takes effect only when printing.
The Code is as follows:
/Style/print.css File
The Code is as follows:
. Noprint {display: none ;}
Using the style in print.css in testprint.html does not show the effect during Webpage Browsing, but it will take effect during printing, as shown in the following section. After noprint is added, it is still realistic in the browser, but it is not displayed when printing:
The Code is as follows:
Of course, you can change the color of the style in print.css as you like (the color image is not effective in the black and white printer, and can be printed in another style). You can use the font or whatever style you like -----------------------------------------------------------------
2. Use JavaScript to control
For that reason, some people may be less proficient in css, some others are more talented in JavaScript, and sometimes JavaScript is a good choice.
The Code is as follows: