IE8 - Only first-child is working

2,558 views
Skip to first unread message

James Greenwood

unread,
Mar 15, 2012, 5:24:24 AM3/15/12
to selectivizr
Hi everyone.

I'm stumped as to why this isn't working as it apparently should. Can
someone please tell me where I am going wrong.

When I view my simple example below in IE9 then switch to IE8
compatibility mode, I only see the first-child selector working.

I've tried with JQuery and NWMatcher. All JS is in the head and is
linking as it should.

<div class="selector-test" style="background:#fff; width:200px; height:
200px;">
<p>Hello world</p>
<p>Hello world</p>
<p>Hello world</p>
<p>Hello world</p>
<p>Hello world</p>
<p>Hello world</p>
<p>Hello world</p>
</div>
<style>
.selector-test p { font-size:22px; color:green; }
.selector-test p:first-child { color:yellow; }
.selector-test p:nth-child(4) { color:blue; }
.selector-test p:last-child { color:pink; }
</style>

Keith

unread,
Mar 15, 2012, 5:40:10 AM3/15/12
to ie-...@googlegroups.com
Move your CSS into an external stylesheet and everything should run fine.

James Greenwood

unread,
Mar 15, 2012, 5:49:50 AM3/15/12
to selectivizr
Hi Keith,

Thanks for your swift reply!

Unfortunately that didn't work either.

I've added this to the head:

<link type="text/css" rel="stylesheet" href="testing-cos.css"
media="all" />

But still the same, only first-child works.

Simon Balarabe

unread,
Mar 15, 2012, 6:10:18 AM3/15/12
to ie-...@googlegroups.com
IE can be a bit of a pain, it sometimes won't load the lastest copy of your document, could you please confirm that your not loading a cached copy of the page as NWMatcher + IE8 should be fine.

James Greenwood

unread,
Mar 15, 2012, 6:13:39 AM3/15/12
to selectivizr
Hi Simon,

'Pain' is not the word I would use :)

Yes, I have IE set to check for a new version of a webpage every time
it is loaded and I've tried manually clearing the cache as well.

Simon Balarabe

unread,
Mar 15, 2012, 7:47:57 AM3/15/12
to ie-...@googlegroups.com
Any chance you could link a static copy of the docuement?

Dan Smith

unread,
Mar 15, 2012, 8:11:51 AM3/15/12
to ie-...@googlegroups.com
Check your sever logs to ensure that IE is actually hitting and loading
the correct files too.

James Greenwood

unread,
Mar 15, 2012, 10:39:22 AM3/15/12
to selectivizr
I'm working locally at the minute until I find out what is causing
this issue.

Here is a link to my files:

http://www.mediafire.com/?l852txd9xlylxol

Simon Balarabe

unread,
Mar 15, 2012, 10:48:31 AM3/15/12
to ie-...@googlegroups.com
The problem is a security related one (I am not 100% sure on the spesifics but something to do with running local javascript files direct from the local FS is preventing it from working), as you are not serving the files via a server (even a locally run one). Try it via a server ;)

James Greenwood

unread,
Mar 15, 2012, 10:56:48 AM3/15/12
to selectivizr
Thanks Simon.

I was working on a server and it didn't work there either :)

That's why I stripped everything back to bare bones, I thought it
would make it easier to spot the problem.

Simon Balarabe

unread,
Mar 15, 2012, 11:06:21 AM3/15/12
to ie-...@googlegroups.com
Weird, the only way it does not work for me is when calling the files locally... the first thing I notices was the JS error, ran it off my VSever and it was fine. I have uploaded it to my personal webspace... can you see if you get an error / prob there as it is fine for me.

Simon Balarabe

unread,
Mar 15, 2012, 11:07:45 AM3/15/12
to ie-...@googlegroups.com

Simon Balarabe

unread,
Mar 15, 2012, 11:10:42 AM3/15/12
to ie-...@googlegroups.com
http://simonbalarabe.com/d/testing-cos.html  the last screanshot seems to have got messed up by the mail client appologies :)

James Greenwood

unread,
Mar 15, 2012, 11:10:52 AM3/15/12
to selectivizr
Can I have a link for that please Simon?

On Mar 15, 3:07 pm, Simon Balarabe <simon.balar...@gmail.com> wrote:

James Greenwood

unread,
Mar 15, 2012, 11:13:09 AM3/15/12
to selectivizr
Thanks Simon!!

I'm just glad to see it working :)

Back to the drawing board then - thanks for all your help guys!

Simon Balarabe

unread,
Mar 15, 2012, 11:18:58 AM3/15/12
to ie-...@googlegroups.com
Any time :)

Ryan Gillies

unread,
Sep 14, 2012, 11:57:26 PM9/14/12
to ie-...@googlegroups.com
Sorry to revive a dead topic, but I'm suffering similar problems with nth-child(odd/even) in IE8, whilst Chrome and Firefox have no issues.  I've got a working copy of the website running here, can anyone shed some light onto why selectivizr isn't implementing the style?

Many thanks, Ryan
Reply all
Reply to author
Forward
0 new messages