...

View Full Version : Print Just A Specific <div>



Basscyst
01-23-2004, 12:46 AM
Hello-

I believe this can be done with CSS - How can I make it so that at print only a specific <div> within the page is printed. Also if this can be accomplished, the div's overflow is set to auto will it print the information that is overflowing? Currently I have a javascript that generates a tabular report displayed in the div, when the user goes to print it out anything that is not currently visible is cut off and not printed. The actual code is extremly lengthy so here is a non working example.


<html>
<head>
<style type="text/css">
.print
{
print:yes;
}
.noprint
{
print:no;
}
</style>
</head>
<body>
<div class="noprint">A whole bunch of whatever</div>
<div class="print">The info I want printed</div>
</body>
</html>


TIA,
Basscyst

oracleguy
01-23-2004, 01:00 AM
You can have another stylesheet that has the media set to print so that when the browser goes to print it uses that and you can hide all the divs you don't want to see and configure the one you how you please.

Basscyst
01-23-2004, 01:42 AM
Awesome **Smacking My Head**- I get it. Sometimes I just need a little push!!! :)

Thanks A Bunch,
Basscyst

J&J
01-23-2004, 06:01 PM
For me, I didn't want the navigation menu & page layout graphics to print, only the main body's content - so I specified which items are hidden and which can be displayed/printed, using a separate CSS specifically for printing only. Example of print.css:

.menu, .altmenu, .footer, .layout img {display: none;}
img, .content img, #body img, #content {display: inline;}


Since I use external CSS, I list the regular CSS as: media="screen"
and list the print CSS as: media="print"

Then you can just use the print preview button on your browser to see how it looks, without wasting paper or ink. :D



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum