Jump to content

using '@media print' prevent areas of page printing, how to do the reverse?


jasonc

Recommended Posts

<style type="text/css">
@media all {
  .page-break { display: none; }
}

@media print
{
  .page-break { display: block; page-break-before: always; }
}

@media print {
div.screenOnly { display: none; }
}
@media print {
div.noborder { border-width: 0px;  border-style: none; }
}

</style>


<div class="screenOnly">
this shows on the screen
</div>

<div>this is printed</div>

 

what I am wanting to do is have a reverse of this so that all the areas i contain within a given <div class="printerOnly"></div> is not shown on the screen but is ready to be printed, when the print button is pressed of course.  and all the other areas are not printed.

 

is this possible ?

Link to comment
Share on other sites

have a read here: http://www.w3.org/TR/CSS2/media.html

 

anyway to set stuff to print when printing you can use

 

div.printOnly { display:none; }
@media print {
div.printOnly { display: block; }
}

 

although I rather make a separate stylesheet for printing and than include it. most people are not very happy with printing out a colorful design.

<link rel="stylesheet" type="text/css" media="print" href="print.css">

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.