<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>遮罩</title>
<style>
* {
margin: 0;
padding: 0;
}
a {
text-decoration: none;
}
.news {
position: relative;
width: 300px;
height: 200px;
margin: 20px auto;
background-color: pink;
}
.news img {
width: 100%;
height: 100%;
}
.news .cover {
display: none;
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
background-color: rgba(0, 0, 0, 0.4);
}
.news .cover a {
position: absolute;
width: 50px;
height: 50px;
top: 50%;
margin-top: -25px;
left: 50%;
margin-left: -25px;
}
.news .cover a img {
width: 100%;
height: 100%;
}
.news:hover .cover {
display: block;
}
</style>
</head>
<body>
<div class="news">
<img src="./news.jpeg" alt="">
<div class="cover">
<a href="#"><img src="./play.jpeg" alt=""></a>
</div>
</div>
</body>
</html>
![在这里插入图片描述](https://img-blog.csdnimg.cn/09654011925c4df6b6c208bfe49cf563.png)
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>遮罩</title>
<style>
* {
margin: 0;
padding: 0;
}
a {
text-decoration: none;
}
.news {
position: relative;
width: 300px;
height: 200px;
margin: 20px auto;
background-color: pink;
}
.news img {
width: 100%;
height: 100%;
}
.news::before {
content: '';
display: none;
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
background: rgba(0, 0, 0, 0.4) url(./play.png) no-repeat center;
cursor: pointer;
}
.news:hover::before {
display: block;
}
</style>
</head>
<body>
<div class="news">
<img src="./news.jpeg" alt="">
</div>
</body>
</html>
![在这里插入图片描述](https://img-blog.csdnimg.cn/e868934538fd474ab523befef7d75b92.png)