How to get odd / crisp coloring for IE and Firefox using only CSS?

I use php for my web project, but I need this coloring set to be only with CSS.

So I need code that works in Firefox and Internet Explorer.

This code is written, but does not work in Internet Explorer:

.tbl_css col:nth-child(odd){      
}

.tbl_css col:nth-child(even){    
}
+5
source share
3 answers

Lower versions of IE will not support pseudo selection.

You can use jQuery to make it work:

$(document).ready(function(){
    $('table tr:even').addClass('even');
    $('table tr:odd').addClass('odd');
});

In CSS, it's simple:

.even{ /* your styles */ }
.odd { /* your styles */ }
+13
source

- :nth-child (IE 9+, FF 3.5+). (, IE 8), class="odd", class="even" JQuery:

$(".tbl_css col:nth-child(2n+1)").addClass("odd");
$(".tbl_css col:nth-child(2n)").addClass("even");

.tbl_css col:nth-child(odd) .odd.
.tbl_css col:nth-child(even) .even.

+7

IE ?

nth-child IE IE9. (IE8 ) .

IE, . HTML- <tr>. JQuery, .

, .

+6

All Articles