I am using the last-child selector to pad out a gap in my nav bar and it all works fine in most browsers, except in the latest version of IE. Are there any solutions or fallbacks for this?
IE7 and IE8 don't support last-child, but they do support first-child. Just gotta switch your coding around to change the first one instead of the last one.
I should mention that the absolute positioning of my nav bar is keeping it to the left and hence the gap at the right. I am not sure how you could reverse this without distorting the output altogether.
Are you sure it's just IE with that problem? It look like you're trying to cover up the gap at the end by adding padding to the last-child list item. So if that's what you're trying to do, it wasn't working in my FireFox 8 either because you weren't giving enough padding: http://jsfiddle.net/7rSMc/3/
It looks like it is still slighty off to me. Using the second method the nav bar is being pushed over the page by 12px. I think I should probably upload to a live server to show you.
I feel like a bit of an idiot. I just should have had the background color in the main selector. I just played with padding and the titles are spread evenly now.
Here is another way of doing it (I'd say this is a better way): http://jsfiddle.net/7rSMc/2/
http://jsfiddle.net/7rSMc/2/ - I added a couple of properties to this selector, namely the background, left and width properties:
An advice would be great!
Is that good enough?
Thanks very much for helping out!
By the way, I can't remember the last time I used :last-child. I'd say it's not necessary 99% of the time.
You can use last-child in ie7-8 with this solution http://divhack.com/node/7