クラスの要素に.parent
カーソルを合わせると、クラスの子要素が検索.child
され、CSSが適用されます。
純粋にCSSでこの効果を達成することは可能ですか?
html:
<div class="parent" style="background:red;margin:20px;padding:20px;">
<div class="child" style="background:blue;margin:20px;padding:20px;"></div>
</div>
<div class="parent" style="background:red;margin:20px;padding:20px;">
<div class="child" style="background:blue;margin:20px;padding:20px;"></div>
</div>
jQuery:
$('.parent').hover(
function () {
$(this).find('.child').css('background','yellow');
},
function () {
$(this).find('.child').css('background','blue');
}
);