Skip to content
View in the app

A better way to browse. Learn more.

Web Designer Forum

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Even and Odd Table Row Colours

Featured Replies

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.

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?

  • 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?

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

  • Author

thank you all. I'm going to give these suggestions a try.

 

Take Care

Create an account or sign in to comment

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.