|
Posted by Vam on February 15, 2005, 1:23 pm
Please log in for more thread options
Hi,
My program makes an HTML report which needs to be easily printable. On this
report is a table, and one of the columns in the table needs to express a
color. I've done this by setting the background of the cells in that column
to their colors (which differ from row to row), but those background colors
don't print unless a certain option is set in IE, which is apparently off by
default. The way we've figured around this is to add a small colored bitmap
to the color cells instead of using their background color property. But
the problem with that is finding the correct size of the bitmap, and the
correct positioning. anybody have any idea how I could get the pixel size
of a cell in an HTML table? And the position that I would need to place a
bitmap so that it covers that cell? Or is there a better way of getting
around this color problem in general, so that it'll always print no matter
what the IE option settings?
|
|
Posted by Barbara de Zoete on February 15, 2005, 9:02 pm
Please log in for more thread options
> The way we've figured around this is to add a small colored bitmap to
> the color cells instead of using their background color property. But
> the problem with that is finding the correct size of the bitmap, and the
> correct positioning. anybody have any idea how I could get the pixel
> size of a cell in an HTML table? And the position that I would need to
> place a bitmap so that it covers that cell? Or is there a better way of
> getting
> around this color problem in general, so that it'll always print no
> matter what the IE option settings?
>
Why IE? The vast amount of browsers out there need to be served, not just
IE.
Anyway, have you considered creating a separate stylesheet for printing so
no background color is needed? Just create a print stylesheet and add it
to your pages through a link element in the head of your document with
appropriate styles.
<link rel="stylesheet" type="text/css" media="print"
href="http://www.foo.invalid/bar/styles/print.css">
If you insist on using that background image, with which you do nobody a
favour really, you don't need to know anything about the dimensions of the
cell it is needed for. Create a tiny image with the correct color, like
4*4px or something like that. Then use some simple style for the
background of your table cells:
table.colored img, .colored th img, .colored td img {
width:100%;
height:100%; }
Any table that has class="colored" added to it, will have any image in its
cells streched to be 100% of both the height and the width of the cell,
regardless its dimensions.
Not tested.
--
,-- --<--@ -- PretLetters: 'woest wyf', met vele interesses: ----------.
| weblog | http://home.wanadoo.nl/b.de.zoete/_private/weblog.html |
| webontwerp | http://home.wanadoo.nl/b.de.zoete/html/webontwerp.html |
|zweefvliegen | http://home.wanadoo.nl/b.de.zoete/html/vliegen.html |
`-------------------------------------------------- --<--@ ------------'
|
|
Posted by Barbara de Zoete on February 15, 2005, 9:24 pm
Please log in for more thread options
> The way we've figured around this is to add a small colored bitmap to
> the color cells instead of using their background color property. But
> the problem with that is finding the correct size of the bitmap, and the
> correct positioning. anybody have any idea how I could get the pixel
> size of a cell in an HTML table? And the position that I would need to
> place a bitmap so that it covers that cell? Or is there a better way of
> getting
> around this color problem in general, so that it'll always print no
> matter what the IE option settings?
>
Why IE? The vast amount of browsers out there need to be served, not just
IE.
Anyway, have you considered creating a separate stylesheet for printing so
no background color is needed? Just create a print stylesheet and add it
to your pages through a link element in the head of your document with
appropriate styles.
<link rel="stylesheet" type="text/css" media="print"
href="http://www.foo.invalid/bar/styles/print.css">
If you insist on using that background image, with which you do nobody a
favour really, you don't need to know anything about the dimensions of the
cell it is needed for. Create a tiny image with the correct color, like
4*4px or something like that. Then use some simple style for the
background of your table cells:
table.colored img, .colored th img, .colored td img {
width:100%;
height:100%; }
Any table that has class="colored" added to it, will have any image in its
cells streched to be 100% of both the height and the width of the cell,
regardless its dimensions.
Not tested.
--
,-- --<--@ -- PretLetters: 'woest wyf', met vele interesses: ----------.
| weblog | http://home.wanadoo.nl/b.de.zoete/_private/weblog.html |
| webontwerp | http://home.wanadoo.nl/b.de.zoete/html/webontwerp.html |
|zweefvliegen | http://home.wanadoo.nl/b.de.zoete/html/vliegen.html |
`-------------------------------------------------- --<--@ ------------'
|
|
Posted by Barbara de Zoete on February 15, 2005, 9:31 pm
Please log in for more thread options
x-posted to alt.html, f'up to alt.html
On Tue, 15 Feb 2005 20:24:04 +0100, Barbara de Zoete
>
Please don't multi post. I didn't understand why my response (in ciwah
appearently) didn't show up (while I was looking at your post in alt.html)
and resent it. Obviously I didn't need to.
Furthermore, where are you going to want the replies? Where are you going
to read them?
Find out about crossposting:
<http://smjg.port5.com/faqs/usenet/xpost.html>
--
,-- --<--@ -- PretLetters: 'woest wyf', met vele interesses: ----------.
| weblog | http://home.wanadoo.nl/b.de.zoete/_private/weblog.html |
| webontwerp | http://home.wanadoo.nl/b.de.zoete/html/webontwerp.html |
|zweefvliegen | http://home.wanadoo.nl/b.de.zoete/html/vliegen.html |
`-------------------------------------------------- --<--@ ------------'
|
| Similar Threads | Posted | | Cannot set background color (XML+CSS) | July 6, 2005, 12:16 am |
| background color of a frame | May 26, 2006, 12:03 pm |
| background-color: #777777 not working in CSS | August 3, 2004, 4:20 pm |
| Cannot print table background color | May 30, 2005, 4:27 am |
| Changing background color of a frameset | June 17, 2005, 2:16 pm |
| how can i change all disabled inputs background color ? | February 28, 2006, 10:58 pm |
| Google tool bar changes text input background color | November 14, 2007, 2:50 pm |
| URGENT: Making rows with background color seemless | June 5, 2008, 10:10 pm |
| Setting an image as background to a table cell. | September 27, 2005, 5:54 pm |
| Printing table cell background colors? | June 10, 2005, 4:24 pm |
|