views:

611

answers:

2

It is frequently asked – but I haven’t seen a good answer yet (and I looked). If you set a background image in CSS to a table row- the image will repeat itself in every cell. If you set the position: relative (for the row) and set the background-image: none (for the cells) it solves the problem on IE but not on chrome! I can't use background positioning since there are many calls and their size varies. (And the picture is not symmetrical- It's a fade out from one side. Anybody??

Example for the css code :

tr { height: 30px; position:relative;}  
tr.green {background: url('green_30.png') no-repeat left top;}  
tr.orange {background: url('oranger_30.png') no-repeat left top;}  
tr.red {background: url('red_30.png') no-repeat left top;}  
td {background-image:none;

}

The HTML is basic - A multi cell table.

The goal is to have different colors fade into every row, but it could be any non-pattern image.

+1  A: 

Ok, I spent ages reading about this, and couldn't find an easy fix for all browsers, but as I see you are using fixed height rows, I've developed my own workaround: http://jsfiddle.net/DR8bM/

Basically, instead of putting the background image on the row, you put it on an absolute-positioned div in the first cell of each row (and expand it to fill the whole row). This is slightly hacky, but may be the only reliable way to achieve what you want.

jackocnr
A: 

I tried using CSS3 gradients instead of graphics, like this:

http://jsfiddle.net/GbR6m/3/

but it does the same thing in Chromium nightly, sorry. I didn't know about jsfiddle before though - it's pretty neat.

References:

dflock