tags:

views:

49

answers:

3

I have a table where the even rows are given the class "even" and the odd rows "odd". But I also want to give the rows classes like "complete" or "problem" that give them other colors, but I still want the hue of the colors to be dark or light depending on if they're even or odd.

Examples

<table>
    <tr class="even problem">
    <tr class="odd complete">
    <tr class="even complete">
    <tr class="odd complete">
    <tr class="even incomplete">
    <tr class="odd complete">
</table>

Will I have to create separate classes for every combination, or is there some other way?

Thanks for all ideas

+2  A: 

Do you mean something like this?

.even{
  background:#ccc;
}

.odd{
  background:#eee;
}

.even.problem{
   background:#900;
}

.odd.problem{
   background:#f00;
}
revaxarts
I'll give it a go. I thought that syntax would select children of the classes even and odd with the class problem
Codemonkey
no, '.parent .children' need a whitespace between
revaxarts
+2  A: 

You could create a semi-transparent PNG file with background for .complete and others classes, so the background color of even and odd class will still be under.

.complete { background: transparent url("path/to/bg.png") top left repeat;}

I didn't test it, but I may work.

Ventus
+1: We've done this. It does work. Incidentally, this is by far the easiest way to apply glass styling to buttons of varying color.
Chris Lively
don't reset the whole 'background' property: just do 'background-image'. You're losing the original background color by using 'transparent'.
Andrew Vit
+1  A: 

I agree too with Ventus's idea. I have created a little demo but instead of using an images a using CSS opacity, to give you a more detailed concept of his idea. The bad thing of using CSS opacity in this example is that your text will inherit the opacity too.

http://jsfiddle.net/ywhR2/

Rubens Mariuzzo
+1 for the example and the link to jsfiddle.net That is a very cool tool.
Chris Lively
Ventus' idea doesn't use opacity: just a PNG background image that is semi-transparent, e.g. 15% black.
Andrew Vit