Forum Moderators: not2easy
A background image seems pretty simple, you just z-index your text layer over the image layer. What do you do if you just want a flexible color layer? My thought is to create a layer with a sufficiently wide color border.
This works in my limited testing but what are the pitfalls and is there a better way?
When you specify the CSS are you adding the media type.
<style type="text/css" title="text/css" media="all">
.theBlocktoPrint
{
background-color: #000;
color: #FFF;
}
</style>
I am not 100% sure and it would be better to get a second opinion but I think I recall the media type effected the way the page printed out.
When we absolutely need to provide a background, e.g. for branding on key products, we link "print version" to a PDF. In other cases we simply put the background color into a foreground graphic. Neither solution is as usable or search-engine friendly, but the marketing department will be happier.
Do you think there is any advantage to printing from a PDF if I can reproduce a printable HTML version that looks extacly the same? I'm thinking maybe the color is reproduced more accurately but I haven't tested.
In the absence of a significant advantage, I would rather produce a single HTML file with a print media-type stylesheet than have two separate documents (and have to re-create PDFs everytime there is a little change).
Thanks for your thoughts.
Now, I'll get off of my soap box. If you still need to do it, because sometimes we need to do things we don't want to, you can use css media=print to add z-indexes to your elements and change images from display:none to display:inline or display:block. Like so:
<style type="text/css">
h1 { background-image: url('whatever.gif'); }
img.h1 { display: none; }
@media print {
h1 { background-image: none!important; z-index: 2!important; }
img.h1 { display: inline!important; z-index: 1!important; }
}
<h1><img src="whatever.gif" class="h1">This is a title with a background</h1>
Please note that I just threw this together and didn't check it at all. You would also need to change the relative positioning of the h1 text.
Also note that there are also problems with printing z-indexes. I've narrowed it down to bad print drivers on select printers. So just because it prints fine for you, it doesnt mean it will print the same way for everyone else. That's why people use PDF's so it always prints the same way. You could also replace the whole text over the image (or color) with just a static image.
I still say just let people print how they want to print. Don't force people to waste their ink.