April 22, 200917 yr I was hoping someone might have a solution to creating Even and Odd background colours to table rows. The data would be coming from a database. I was hoping for an all CSS solution, but am really open to anything. I read something about tr:nth-child but it doesn't seem to work in IE. Any help would be greatly appreciated.
April 22, 200917 yr Can't you just create a class in your stylesheet which has the background colour you want, and apply it to every second row of the table?
April 22, 200917 yr Author Can't you just create a class in your stylesheet which has the background colour you want, and apply it to every second row of the table? Hi There. Unfortunately I'm unable to do this, because the data is coming from salesforce.com. The info would be coming in dynamically, so I'm looking for a solution that would apply the coloured background based on odd/even numbers. I hope that made sense. I wish I was able to just add a simple class. Any Ideas?
April 22, 200917 yr there are two options: first one is css. if everything is being called in order you could add an extra bit in your database so that it will call the class in the tr. So much like you are calling the data into the cells you would call either class even or class odd into <tr class="... If you can't be bothered with the manual way or can't actually do it like that, then you could use a bit of JS to do it for you, here is an example: http://www.aggiorno.com/blogs/aggiornings/...ith_jquery.aspx
April 22, 200917 yr Zebra tables are a great way to display data in a manner easy on the eyes. Elite Zebra Tables 2.1
Create an account or sign in to comment