I have a div that contains: text , backround color, image
and i want to print only this div.
I'm kind of clueless so any help could help
thanks.
I have a div that contains: text , backround color, image
and i want to print only this div.
I'm kind of clueless so any help could help
thanks.
You need to define a print stylesheet. You do this in the following manner:
<link rel="stylesheet" href="your url" type="text/css" media="print" />
In that sheet you specify how to display your website for the printed page. So what you can do is set every element to display:none
except for the div you wish to print.
You can do this easily with the following selectors:
* {
display: none;
}
#printDiv {
display: block;
}
and simply apply the id printDiv
to the div you wish to print.
What have u tried?
Maybe this helps:
You require to create new style sheet print.css and set CSS media=print
for example :
<style media="screen">
.noPrint{ display: block; }
.yesPrint{ display: block !important; }
</style>
<style media="print">
.noPrint{ display: none; }
.yesPrint{ display: block !important; }
</style>
Giv the specific div the .yesPrint
class and all other the .noPrint
.
I have recently used this JQuery plugin to do something similar
http://projects.erikzaadi.com/jQueryPlugins/jQuery.printElement/