为什么悬停不起作用.CSS RGBA无法正常工作

时间:2018-01-19 13:12:29

标签: css3 hover opacity rgba

为什么rgba悬停不起作用? 这是我的代码

.img {
width: 100%;
height: 250px;
background: url(http://cos.jpg) no-repeat;
background-size: cover;
margin-bottom: 20px;

不工作rgba

.image:hover{
background-color: rgba(251, 181, 59, 0.5);

1 个答案:

答案 0 :(得分:1)

可能是你没有正确关闭图像样式。检查您的代码一次。同时试试我的例子,这里的图像悬停工作正常,我只是给了一些边框以便更好地理解,这可能会对你有所帮助。



<!DOCTYPE html>
<html>
<head>
<style> 
.main{
padding:20px;
margin:20px;
}
.img {
width: 200px;
height: 200px;
background: url("https://www.w3schools.com/cssref/img_tree.gif") no-repeat;
padding:20px;
margin:20px;
}
.img:hover{
background-color: rgba(255, 255, 0, 0.9);
border:5px solid green;
}
</style>
<body>
<div class="main">
	<div class="img"></div>
</div>
</body>
</html>
&#13;
&#13;
&#13;