css - 悬停在 div 上时更改链接颜色,当悬停链接时也会更改链接颜色

标签 css hyperlink hover

抱歉,如果标题有点具体,但这将为我的网站画龙点睛。这是我当前的代码:

.social {
	background-color: rgba(150,150,150,0.75);
	height: 150px;
	width:200px;
	margin: 20px;
	display: inline-block;
    transition: background .25s ease, box-shadow 0.20s ease-in-out, color 0.20s ease;
    font-weight: bold;
    
}
.social:hover {
	
    background-color: rgb(118, 118, 118);
	box-shadow: 0px 0px 2px 3px rgba(125,125,125,0.75);
    color: rgb(255,255,255);
    
}

.social:hover a {
    color: rgb(255,255,255);
}
a {
    color: rgb(20, 0, 255);
    transition: color 0.5s;
}

a:hover {
    color: rgb(0, 255, 10);
    text-decoration: underline;
    
}
<div class="social"> <span>Blank</span>  <br> <span> Blank</span> <p> <a href="http://www.twitter.com"> Hello <i class="fa fa-twitter"></i></a> <a href="http://www.facebook.com" target="_blank"><i class="fa fa-facebook-official"></i></a> <a href="http://www.plus.google.com" target="_blank"><i class="fa fa-google-plus"></i></a> <a href="http://www.instagram.com" target="_blank"><i class="fa fa-instagram"></i></a></p> </div>
当我将鼠标悬停在 div 上时,它会变灰,而文本会变白,这正是我想要的。但是,我想要这样,当您将鼠标悬停在链接上时,它会变成浅绿色。

提前致谢。

最佳答案

编辑了您的示例。

您需要在 <a> 上指定悬停以及将鼠标悬停在 div 上

.social {
	background-color: rgba(150,150,150,0.75);
	height: 150px;
	width:200px;
	margin: 20px;
	display: inline-block;
    transition: background .25s ease, box-shadow 0.20s ease-in-out, color 0.20s ease;
    font-weight: bold;
    
}
.social:hover {
	
    background-color: rgb(118, 118, 118);
	box-shadow: 0px 0px 2px 3px rgba(125,125,125,0.75);
    color: rgb(255,255,255);
    
}

.social:hover a {
    color: rgb(255,255,255);
}
.social:hover a:hover {
    color: rgb(0, 255, 10);
}
a {
    color: rgb(20, 0, 255);
    transition: color 0.5s;
}
<div class="social"> <span>Blank</span>  <br> <span> Blank</span> <p> <a href="http://www.twitter.com"> Hello <i class="fa fa-twitter"></i></a> <a href="http://www.facebook.com" target="_blank"><i class="fa fa-facebook-official"></i></a> <a href="http://www.plus.google.com" target="_blank"><i class="fa fa-google-plus"></i></a> <a href="http://www.instagram.com" target="_blank"><i class="fa fa-instagram"></i></a></p> </div>

关于css - 悬停在 div 上时更改链接颜色,当悬停链接时也会更改链接颜色,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28727095/

相关文章:

javascript - 如何让我的游戏角色留在 Canvas 内?

html - 两个固定导航 - 如何在它们之间居中放置 block

html - css/html 不适用于 Internet Explorer,但适用于 chrome 和 safari

linux - 协调 Kaldi 食谱的链接和路径文件

jquery - fancybox - 如何添加打开图像的链接?

html - 尝试使用悬停使图像消失但文字挡住了

html - 在 Chrome 的检查器开发工具 ("Inspector stylesheet"中添加新空白样式表的最快方法)

javascript - 将随机类应用于元素

java - 如何通过将鼠标悬停在变量上来显示变量值

html - 将鼠标悬停在 div 上时,如何在链接上触发多个悬停操作?