I never said that this was a one size fits all solution. It would help to understand that css means cascading style sheet. That means that whatever you set ripples down in many cases from a parent element to all of its children. If one child is display none, all of its children will be as well.
A direct child is like:
Code:
<body>
<div>won't print</div>
<div id="print_div">This will print</div>
</body>
Both div's are direct children of the body, and using our print styles, the print_div will get printed. But here:
Code:
<body>
<div><div id="print_div">won't print</div></div>
</body>
only the highlighted one is a direct child of the body. Our print styles will render it and all of its children (in this case our print_div) display: none. So our print_div will not get printed.
On your page you have many nested levels of elements and some are tables. Tables and their intrinsic descendant elements (like th, td, tr, tbody) cannot be made display: block; and be expected to render correctly in all browsers. So in addition to taking nesting into account, a different property (properties in this case - visibility and position) other than display would be easier to work with as they both default to the same thing (respectively - visible and static) regardless of the element they apply to and can be used together to render an element unseen and out of the flow of a page. Additionally there are other styles (border, background, color) involved here on elements that cannot be made to disappear without losing the content that you want, yet those styles must still be dealt with if you want a clean printed page.
Anyways, these print styles appear to work well with the example page:
Code:
<style type="text/css">
@media print {
body * {
visibility: hidden;
position: absolute;
}
* {
background: white!important;
color: black;
border-width: 0!important;
}
#post_message_886182, #td_post_886182, #post886182, #post886182 tr, #post886182 tbody, form {
visibility: visible;
position: static;
width: 100%;
}
}
</style>
Notice the repeated use of the post number (886182). I assume this can be supplied via PHP. If not, this would be a difficult, perhaps impossible solution to implement.
Also notice the !important keyword. This is required to override inline styles on elements where/if present.
Bookmarks