473,387 Members | 3,820 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

cell background color

Vam
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?
Jul 23 '05 #1
3 5497
On Tue, 15 Feb 2005 12:23:30 -0600, Vam <ie@explorem.com> wrote:
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 |
`-------------------------------------------------- --<--@ ------------'
Jul 23 '05 #2
On Tue, 15 Feb 2005 12:23:30 -0600, Vam <ie@explorem.com> wrote:
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 |
`-------------------------------------------------- --<--@ ------------'
Jul 23 '05 #3
x-posted to alt.html, f'up to alt.html

On Tue, 15 Feb 2005 20:24:04 +0100, Barbara de Zoete
<b_********@hotmail.com> wrote:
On Tue, 15 Feb 2005 12:23:30 -0600, Vam <ie@explorem.com> wrote:


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 |
`-------------------------------------------------- --<--@ ------------'
Jul 23 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: John A. | last post by:
Hello all! I've got a big bunch of pages using tables for layout. Eventually I'll get them set up with more modernized code, but in the meantime I'd like to slip in a little quick holiday...
1
by: dhunter | last post by:
I'm kind of new to CSS and hope someone knows how to fix a problem I've been fighting with for days. I'm trying to create a mouseover navbar with CSS which inserts a colored background JPG that...
31
by: Arthur Shapiro | last post by:
I'm the webmaster for a recreational organization. As part of one page of the site, I have an HTML "Calendar at a Glance" of the organization's events for the month. It's a simple table of a...
5
by: Greg N. | last post by:
Hi folks, I have a table cell with a background image, something like <td background=landscape.jpg height=200></td> The sole purpose of this code is to display the image inside that table...
3
by: Peter Williams | last post by:
Hi All, I want to write some javascript for a html page which does the following. Imagine that the page contains a table with 2 columns and 3 rows, e.g.: +---+---+ | A | B | +---+---+
5
by: Doug Laidlaw | last post by:
HTML validators say that "background" is not a valid attribute for a <td> tag I want to set an image as the background for one cell only, and to have the cell content on top of it. If I can't...
5
by: nivas.meda | last post by:
Hi, I have an excel sheet with a graph and cells.If i change the value in the excel cells the graph will reflect.Now i am going to implement this functionality in html page.I successfully saved...
1
by: Thanks | last post by:
I have a routine that is called on Page_Init. It retrieves folder records from a database which I display as Link Buttons in a table cell. I set the table cell's bgcolor to a default color (say...
1
by: Manil | last post by:
I usually have no problem with Firefox, but here is a rare instance of IE displaying a table with image slices correctly and Firefox adding space where I seemingly have none. Is there anything I can...
2
by: patrick.waldo | last post by:
Hi all, I am trying to figure out a way to read colors with xlrd, but I did not understand the formatting.py module. Basically, I want to sort rows that are red or green. My initial attempt...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.