【发布时间】:2017-07-03 03:31:33
【问题描述】:
我有一个带有社交链接的 div,当悬停任何具有不同颜色的锚点时,我想让背景颜色填充整个 div,具体取决于悬停的链接。
目前,背景仅在锚文本下方发生变化。
我正在研究使用纯 CSS 用孩子的背景颜色填充整个父母的方法。
#social {
width: 400px;
height: 300px;
position: relative;
font-size: 36px;
font-weight: bold;
text-align: center;
}
a:link {
text-decoration: none;
transition: all .5s ease;
}
a:hover {
color: white;
}
#facebook:hover {
background: #3b5998;
}
#twitter:hover {
background: lightblue;
}
#google-plus:hover {
background: tomato;
}
#instagram:hover {
background: lightgreen;
}
<div id="social">
<a id="facebook" href="#"> <span>Facebook</span></a><br>
<a id="twitter" href="#"> <span>Twitter</span></a><br>
<a id="google-plus" href="#"> <span>Google plus</span></a><br>
<a id="instagram" href="#"> <span>Instagram</span></a><br>
</div>
【问题讨论】: