I'm having trouble getting this working in most browsers, except for IE (it even works correctly in IE6) and Opera.
Firefox separates the divs correctly but only prints the first page.
Chrome and Safari only applies the page break to the last div.
How can I get this working across all browsers correctly?
The HTML:
<div id="leftNav">
<ul>
<!--links etc-->
</ul>
</div>
<div id="mainBody">
<div id="container">
<div class="pageBreak">
<!--content-->
</div>
<div class="pageBreak">
<!--content-->
</div>
<div class="pageBreak">
<!--content-->
</div>
</div>
</div>
The divs with the IDs #leftNav
and #mainBody
are are set to float:left
, so they display nicely.
I only want to print the .pageBreak
classes, hiding the #leftNav
and the rest of the #mainBody
with CSS.
The CSS:
@media print
{
#leftNav
{
display:none;
}
#mainBody
{
border:none;
margin:none;
padding:none;
}
}
[solved]
to your question's title (which doesn't do anything really). Also note that SitePoint reference (which sepehr linked to below) is a much better reference for CSS and HTML than W3Schools – Thirzia