<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<style>
* {
margin: 0;
padding: 0;
}
.container {
width: 1380px;
height: 350px;
margin: 100px auto;
overflow: hidden;
}
.wrapper {
width: 1400px;
}
.box {
width: 345px;
height: 350px;
float: left;
position: relative;
overflow: hidden;
}
.box .title {
width: 345px;
height: 350px;
background-color: #ddd;
}
.box .content {
position: absolute;
top: 0;
left: 345px;
}
</style>
</head>
<body>
<div class="container">
<div class="wrapper">
<div class="box">
<div class="title" style="">"></div>
<div class="content"><img src="https://img.zcool.cn/community/"
></div>
</div>
<div class="box">
<div class="title" style="">"></div>
<div class="content"><img src="https://img.zcool.cn/community/"
></div>
</div>
<div class="box">
<div class="title" style="">"></div>
<div class="content"><img src="https://img.zcool.cn/community/"
></div>
</div>
<div class="box">
<div class="title" style="">"></div>
<div class="content"><img src="https://img.zcool.cn/community/"
></div>
</div>
</div>
</div>
<script src="https://cdn.bootcss.com/jquery/3.4.1/jquery.min.js"></script>
<script>
// 1. 让当前的盒子,宽度变成1380px; 让其与的盒子宽度变成0;
// 2. 移出的时候让所有的盒子宽度变成345px;
$(".box").mouseover(function () {
$(this)
.stop(true)
.animate({
width: 1380
})
.siblings(".box")
.stop(true)
.animate({
width: 0
})
.end()
.children(".content")
.css({
left: 0
})
})
$(".box").mouseout(function () {
$(".box")
.stop(true)
.animate({
width: 345
})
.queue(function () {
$(this)
.children(".content")
.css({
left: 345
})
})
})
</script>
</body>
</html>