为什么这个CSS选择器不工作:a:hover〜span? [英] Why doesn't this CSS selector work: a:hover ~ span?

查看:148
本文介绍了为什么这个CSS选择器不工作:a:hover〜span?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

  a:hover + span {background:yellow; } 
a:hover> span {background:yellow; }
a:hover〜span {background:yellow; }

前两个选择器工作正常。但是,第三个选择器不工作?



演示: http: //jsfiddle.net/UAHw7/



为什么?






更新:我启用了所有浏览器...



Opera 11 - 工作

Safari 5 - 工作

Firefox 3.6 - 工作

IE9 RC - 工作

Chrome 9 - 无法使用



Chrome问题...






注意:由于Chrome不再包含此错误,因此此问题已过时。


解决方案

与使用:hover 伪类相关的Webkit错误。



所有浏览器的IE 8中的b 3.6 b



  • in Opera 11



不适用于我




  • 在Chrome 9中

  • 在Safari 5.0.3中



- 值得。


a:hover + span { background:yellow; }
a:hover > span { background:yellow; }
a:hover ~ span { background:yellow; }

The first two selectors work just fine. However, the third selector does not work?

Demo: http://jsfiddle.net/UAHw7/

Why?


Update: I fired up all my browsers ...

Opera 11 - Works
Safari 5 - Works
Firefox 3.6 - Works
IE9 RC - Works
Chrome 9 - Does not work

A Chrome issue then ...


Note: As Chrome no longer contains this bug, this question is obsolete.

解决方案

Looks like a Webkit bug related to using the :hover pseudo-class.

It works fine for me

  • in FF 3.6.13
  • in IE 8 of all browsers
  • in Opera 11

It doesn't work for me

  • In Chrome 9
  • In Safari 5.0.3

Might be file-worthy.

这篇关于为什么这个CSS选择器不工作:a:hover〜span?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆