Webkit bug with `:hover` and multiple adjacent-sibling selectors

Safari and Chrome, as well as Opera and Firefox, can handle the :hover pseudo-class and adjacent-sibling selectors:

a:hover + div {}

This works.

However, when another adjacent-sibling is added:

div:hover + a + div {}

Webkit falls apart.

However, if you first hover over <a> and then hover over the <div> the style is applied as it ought to.

I'm further confounded, because if you add:

div:hover ~ div {}

with or without a style declared, it starts working as it ought to.

Demo

I see this problem in:

  • Google Chrome 15.0.874.121
  • Safari 5.1.1

for OS X.

Any ideas?

Answers


you can overcome Webkit's pseudo classes + general/adjacent sibling selectors bugs by faking animation on the body element:

body { -webkit-animation: bugfix infinite 1s; }

@-webkit-keyframes bugfix { 
  from { padding: 0; } 
  to { padding: 0; } 
}

you can check it out here: http://jsfiddle.net/jalbertbowdenii/ds2yY/1/


Easy Fix without Animations

Handled a similar issue here, where this idea of changed pseudo-classes solved it (note: nth-child(n) will always match):

div:hover + a:nth-child(n) + div

Alternatively, the fix can be applied only to the elements that are having the update issue rather than to the body element:

http://jsfiddle.net/ds2yY/12/

.force-repaint { -webkit-animation: bugfix infinite 1s; }

@-webkit-keyframes bugfix {
    from { fill: 0; }
    to { fill: 0; }
}

Need Your Help

IE6 Frames & Memory Leak

jquery jquery-ui frames internet-explorer-6

Before I start this question, I understand that every aspect of it is wrong. Please keep that in mind...

What's a good image hosting site with an API to allow me upload images from my website?

image api file-upload image-uploading

I'm looking for an image hosting website that'll allow me to upload images onto their servers from my own website using an API. I like Imgur.com's API but I'm looking for alternatives.