Code Snippet Submit one! Home » Code Snippets » CSS » CSS3 Zebra Striping a TableCSS3 Zebra Striping a Tabletbody tr:nth-child(odd) { background-color: #ccc; }
great certainly saved me some time searching
this didn’t work well for me, but the PHP one worked great.
CSS3 zebra striping is better solution! Why? Here is the right concept:
1. PHP generates html as output, which should not care how the elements looks like.
2. CSS purpose is to “care” how the elements looks like.
Cant understand, how it works…
@Dyllon and @Artem, here is a simple demo explaining how to use this code, and a live example of it being used.
http://webdesignandsuch.com/2010/08/add-zebra-striping-to-a-table-with-css3/
Sadly… not supported by IE
Can be done with jQuery addClass.
shitty explorer not supported
I bet these people saying that it isn’t working are browsers that are not supported. :D
I meant, *using* browsers that are not supported.
Just wanted to say thanks for all of the cool tips and tricks. I’ve used the css zebra stripe trick before but it hadn’t occurred to me to prefix my css with tbody so that I could better target hovers and such.
How do you maintain a consistent zebra pattern in a sortable PHP table?
This is awesome, sadly it’s not working in IE. Therefore I am using the PHP or jQuery way, until IE wakes up and shuts down that terrible browser.
DigWP
A book and blog co-authored by Jeff Starr and myself about the World's most popular publishing platform.
Quotes on Design
Design, like Art, can be an elusive word to define and an awfully fun thing to have opinions about.
HTML-Ipsum
One-click copy to clipboard access to Lorem Ipsum text that comes wrapped in a variety of HTML.
Bookshelf
Hey Chris, what books do you recommend? These, young fertile mind, these.