I have the following
@media print { DIV { display: block; } }
<html> <body> <div style="display:none">You can't see me!</div> </body> </html>
But when I tried this, I still couldn't see "You can't see me!" when I print. How can I get this to show up for printing?
Assign a class to your div
so you can specify what needs to be seen when being printed:
<html>
<body>
<div class="print-only">You can't see me!</div>
</body>
</html>
Then your CSS would look like:
.print-only {
display: none;
}
@media print {
.print-only {
display: block !important;
}
}
First of all, from your code I can see you use an inline style of display: none
. This will prevent the div from showing. Remove the inline style to correct this.
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.