鼠标hover时改变图片透明度和颜色

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>鼠标hover时改变图片透明度和颜色</title>
<style>
* {
margin:0;
padding: 0;
}

.wrap{
border: 1px solid pink;
300px;
height:250px;
position: relative;
overflow: hidden;
}
.pic,.bac {
300px;
height:250px;
position: absolute;
}
.bac {
background: pink;
opacity: 0.6;
display: none;
}
img {
300px;
height:250px;
}
.wrap:hover .bac{
display: block;
}
.wrap:hover .txt{
display: block;
}
.txt {
font-size: 40px;
position: absolute;
text-align: center;
left: 50%;
top:30%;
color:orangered;
display: none;
}
</style>
</head>
<body>
<div class="wrap">
<div class="pic">
<img src="img/1.png">
</div>
<div class="bac"></div>
<div class="txt">+</div>
</div>
</body>
</html>
原文地址:https://www.cnblogs.com/iriliguo/p/6477401.html