我很好奇为什么这不起作用?我的猜测是,无论您的目标是什么元素,您都必须通过其父元素。我是对的还是有窍门?(没有jQuery)
查看小提琴:http: //jsfiddle.net/eMw5C/
HTML
这不起作用
三角枪 <h1>This Works</h1>
<div class="yes-working">
<img src="https://i158.photobucket.com/albums/t109/hp_arianepotter/trigun-1.png" />
<a href="javascript:void(0);">Trigun</a>
</div>
/* This doesn't work */
.not-working img { width: 10em; clear: both; }
.not-working img:hover a { color: red; }
.not-working a { color: black; }
.not-working a:hover { color: red; }
/* This works */
.yes-working img { width: 10em; clear: both; }
.yes-working:hover a { color: red; }
.yes-working a { color: black; }
.yes-working a:hover { color: red; }