:hover失效的奇怪问题
- HTML code
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><title> new document </title><style type="text/css">.b .c { background:#ffff99;}span:hover { background:#5b1672;}</style></head><body> <div class="b"> <span class="c"> asdddffgghh </span> </div></body></html>
上面的:hover失效了,写成下面的几种都正常,为什么上面的不行,谁能解释下,谢谢
- CSS code
.b .c { background:#ffff99;}.b span:hover { background:#5b1672;}
- CSS code
.c { background:#ffff99;}span:hover { background:#5b1672;}
- CSS code
.c { background:#ffff99;}.b span:hover { background:#5b1672;}
[解决办法]
2个地方定义一个属性,究竟使用哪个,这涉及到css 优先权的问题。