DISCLAIMER,
I am not a programmer.
What would be the easiest way to implement alternating css row colors in a table for a drupal 7 theme? Thanks!
To augment @Clive's answer, drupal also adds a CSS class of "odd" and "even" to each TR element in the default theme table, so you could use them, too, eg:
tr.odd { background-color: #ccc; }
tr.even { background-color: #aaa; }
These are based on the $zebra
variable that is available in a lot of templates just for this purpose.
theme_table()
but it might not catch everything...safest thing would probably be to add both sets of rules, then all bases are covered
The easiest way would be straight CSS using the :nth-child
pseudo-selector:
tr:nth-child(even) td { background: #ccc; }
tr:nth-child(odd) td { background: #aaa; }
The usual caveats apply (i.e. it doesn't work in Internet Explorer <9)