Hide all elements except one div for print view

前端 未结 9 2119
无人及你
无人及你 2020-12-10 10:38

I have the following CSS for my print style:

* {
 display:none;
}

#printableArea {
 display:block;
}
9条回答
  •  清歌不尽
    2020-12-10 11:03

    Answering because I found this question while searching for this

    Instead of 'display: none' you can use :

    * {
         visibility: hidden;
         margin:0; padding:0;
        }
    
        #printableArea * {
          visibility: visible;
        }
    

    source : https://www.concrete5.org/community/forums/5-7-discussion/need-to-print-a-certain-div-and-ignore-everythign-else-on-the-pa

提交回复
热议问题