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){ }
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 */ }
- :nth-child (IE 9+, FF 3.5+). (, IE 8), class="odd", class="even" JQuery:
:nth-child
class="odd"
class="even"
$(".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.
.tbl_css col:nth-child(odd)
.odd
.tbl_css col:nth-child(even)
.even
IE ?
nth-child IE IE9. (IE8 ) .
nth-child
IE, . HTML- <tr>. JQuery, .
<tr>
, .