HTML
<!DOCTYPE html>
<html lang="en">
<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>Document</title>
<link rel="stylesheet" href="index.css">
</head>
<body>
<div class="image">
<img src="./R-C.jpg" alt="">
</div>
<div class="image">
<img src="./R-C.jpg" alt="">
</div>
<div class="image">
<img src="./R-C.jpg" alt="">
</div>
</body>
</html>
CSS
body{
margin: 0;
padding: 0;
height: 100vh;
display: flex;
align-items: center;
justify-content: center;
background-color: #333 ;
}
.image{
width: 260px;
overflow: hidden;
position: relative;
cursor: pointer;
margin: 0,20px;
}
.image img{
width: 100%;
}
.image::before{
content: '';
position: absolute;
left: 0;
top: 0;
width: 100%;
height: 100%;
background-size: cover;
filter: grayscale(100%);
transition: .5s linear;
}
.image:hover::before{
width: 0;
}
.image:nth-child(1)::before{
background-image: url(./R-C.jpg);
}
.image:nth-child(2)::before{
background-image: url(./R-C.jpg);
}
.image:nth-child(3)::before{
background-image: url(./R-C.jpg);
}
图片随便找 反正image100%缩放的