Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CSS pseudo-class fallback?

I'd like to use the tr:nth-child(even/odd) pseudo class for a table, but I want to support the IE 2 population as well. So, is there any purely css way to add a border to tr if nth-child isn't supported?

like image 655
tkbx Avatar asked Jan 23 '26 16:01

tkbx


1 Answers

You can try Selectivizr, I think that's the easiest solution.

EDIT:

You could also use jquery to add classes for you:

$(function() {
    $("tr:odd").addClass("odd");
    $("tr:even").addClass("even");
});

EDIT2:

Also, if you're using Modernizr, you could try this.

EDIT3 :)

tr { border-bottom: 1px solid #ccc; }

tr:nth-child(odd),
tr:nth-child(even) { border: none; }

tr:nth-child(odd) { background: #eee; }

tr:nth-child(even) { background: #ddd; }
like image 150
Adaz Avatar answered Jan 25 '26 12:01

Adaz