<!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>
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
.box {
/* 超出部分隐藏 */
overflow: hidden;
width: 1366px;
height: 600px;
background-color: pink;
background: url(./images/bg.jpg) no-repeat;
margin: 100px auto;
}
.box::before,
.box::after {
content: '';
width: 50%;
height: 600px;
/* 谁做过渡给谁加 */
transition: all .5s;
background: url(./images/fm.jpg) no-repeat;
}
.box::before {
float: left;
background-color: aqua;
}
.box::after {
float: right;
background-color: red;
background-position: right center;
}
/* 鼠标经过box大盒子 让里面的两个小盒子 before 和after 进行拉动*/
.box:hover::before {
/* 百分比是盒子自身的宽度 */
transform: translateX(-100%);
}
.box:hover::after {
transform: translateX(100%);
}
</style>
</head>
<body>
<div class="box"></div>
</body>
</html>