简体   繁体   中英

Is there a way I can hide a DIV when I am doing a print of my page with CSS?

I would like to print my page without headings.

Is there a way I can:

  • make the heading <DIV id="heading"> not show when I am doing a print

  • and make a <DIV id="summary"> show only when doing a print?

@media print { 
 #heading{
  display:none;
 }
 #summary{
  display:block;
 }
}

try to hide/show them via @media blocks:

inside css:

@media print {
  #heading {
    display: none !important;
  }
}
@media screen {
  #summary{
    display: none !important;
  }
}

.heading{display:none;}

means setting the display property to none ..will hide the element

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM