Use CSS to hide contents on print

后端 未结 5 1668
萌比男神i
萌比男神i 2020-12-15 09:07

I’m looking for an easy way to hide everything except a certain div and its contents.


  
  
    
5条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-12-15 09:41

    @media print {
    .noPrint {
        display:none;
      }
    }
    

    Now you need to apply the class noPrint to the elements you want to hide in printing.


    It is good practice to use a style sheet specifically for printing, and and set it's media attribute to print.

    Example:

    
    

提交回复
热议问题