效果
代码
<!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>
<style>
.father {
position: relative;
width: 100px;
height: 100px;
background-color: pink;
margin: 100px auto;
overflow: hidden;
}
.son {
position: absolute;
left: 0;
top: 0;
width: 200px;
height: 100%;
background-color: #fff;
transition: all .5s;
}
.son .img1,
.son .img2 {
float: left;
height: 100%;
width: 50%;
}
.father:hover .son {
left: -100px;
}
</style>
</head>
<body>
<div class="father">
<div class="son">
<img src="lg1.jpg" alt="" class="img1">
<img src="lg2.jpg" alt="" class="img2">
</div>
</div>
</body>
</html>