Victor
Victor

Reputation: 489

last-child and nth-child with IE7 and IE8

Ok so I need to add a background color to the last row in the all the tables except the last table where I need to add a background color to the last three rows.

table tbody tr:last-child    
table:last-child tbody tr:nth-last-child(-n+3)

How do I make this work in IE7 and IE8?

Preferably a CSS-only solution. Will a solution like Modernizr solve this? I prefer not to travers the dom with jQuery and add custom classes/styles with my own script.

Upvotes: 2

Views: 6905

Answers (2)

Brian
Brian

Reputation: 2829

CSS-only solution not possible, you are dealing with browsers that are way too old. On the upside, you don't need your own script as Selectivzr does just this, or alternatively the all-in-one solution that is IE9.js (fixes a ton of other IE bugs, not just add new selectors).

Upvotes: 2

madlee
madlee

Reputation: 647

short answer: no to a css-only solution;

modernizr isn't going to give the css engine in old ie any additional features. Your best bet is to either a) add classes to the rows you want styled differently or b) do it with javascript. If you are generating the tables dynamically (with php, for example) then adding classes there is easier.

Upvotes: 2

Related Questions