我希望在鼠标悬停在“文章”标签上时更改背景颜色以更改类overlayLink的背景颜色
这是我的代码
.parent {
width: 400px;
height: 150px;
position: relative;
border: 1px solid #000;
}
.overlayLink {
background-color: red;
width: 100%;
height: 100%;
display: block;
}
.overlayLink:hover {
color: #fff;
background-color: #000;
}
article {
position: absolute;
bottom: 0;
left: 0;
width: 100%;
height: 50px;
background-color: #efefef;
}
<div class="parent">
<a href="#" class="overlayLink">a</a>
<article>
abcdefghijk
</article>
</div>
答案 0 :(得分:3)
您可以使用此
.parent {
width: 400px;
height: 150px;
position: relative;
border: 1px solid #000;
}
.overlayLink {
background-color: red;
width: 100%;
height: 100%;
display: block;
}
.parent:hover .overlayLink {
color: #fff;
background-color: #000;
}
article {
position: absolute;
bottom: 0;
left: 0;
width: 100%;
height: 50px;
background-color: #efefef;
}
&#13;
<div class="parent">
<a href="#" class="overlayLink">a</a>
<article>
abcdefghijk
</article>
</div>
&#13;
答案 1 :(得分:0)
可能会有所帮助。
.parent {
width: 400px;
height: 150px;
position: relative;
border: 1px solid #000;
}
.overlayLink {
background-color: red;
width: 100%;
height: 100%;
display: block;
}
.parent:hover .overlayLink {
color: #fff;
background-color: #000;
}
article {
position: absolute;
bottom: 0;
left: 0;
width: 100%;
height: 50px;
background-color: #efefef;
}
&#13;
<div class="parent">
<a href="#" class="overlayLink">a</a>
<article>
abcdefghijk
</article>
</div>
&#13;
.parent {
width: 400px;
height: 150px;
position: relative;
border: 1px solid #000;
}
.overlayLink {
background-color: red;
width: 100%;
height: 100%;
display: block;
}
.overlayLink:hover {
color: #fff;
background-color: #000;
}
article {
position: absolute;
bottom: 0;
left: 0;
width: 100%;
height: 50px;
background-color: #efefef;
}
&#13;
<div class="parent">
<a href="#" class="overlayLink">a</a>
<article>
abcdefghijk
</article>
</div>
&#13;