使用CSS,如何在父项悬停时更改子项的属性?
答案 0 :(得分:2)
选择父元素并使用:hover
伪类,然后选择要更改其属性的子项。
.wrp {
padding: 15px;
}
.wrp:hover .hvr {
background: #FFFF33;
}
<div class="wrp">
<span class="hvr">Hover my parent</span>
</div>
答案 1 :(得分:0)
.parent:hover .first-child {
background: red;
}
.parent:hover .second-child {
background: blue;
}
.parent:hover .third-child {
background: green;
}
&#13;
<div class="parent">
<div class="first-child">Lorem Ipsum</div>
<div class="second-child">Lorem Ipsum</div>
<div class="third-child">Lorem Ipsum</div>
</div>
&#13;