HTML:
<!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;
}
.box {
width: 769px;
height: 115px;
margin: 200px auto;
background: url("images/nav.png") no-repeat;
padding: 20px;
}
.img {
display: block;
}
ul {
list-style: none;
}
.box ul {
overflow: hidden;
}
.box li {
width: 69px;
height: 69px;
margin-right: 10px;
float: left;
position: relative;
}
.box .current {
width: 224px;
}
.box .current .big {
display: block;
}
.box .current .small {
display: none;
}
.big {
display: none;
width: 224px;
}
.small {
display: block;
position: absolute;
width: 69px;
height: 69px;
left: 0;
top: 0;
border-radius: 5px;
}
</style>
<script src="jquery-3.5.1.min.js"></script>
</head>
<body>
<div class="box">
<ul>
<li class="current">
<a href="#">
<img src="images/m2.jpg" alt="" class="small">
<img src="images/m1.png" alt="" class="big">
</a>
</li>
<li>
<a href="#">
<img src="images/m4.jpg" alt="" class="small">
<img src="images/m3.png" alt="" class="big">
</a>
</li>
<li>
<a href="#">
<img src="images/m6.jpg" alt="" class="small">
<img src="images/m5.png" alt="" class="big">
</a>
</li>
<li>
<a href="#">
<img src="images/m8.jpg" alt="" class="small">
<img src="images/m7.png" alt="" class="big">
</a>
</li>
<li>
<a href="#">
<img src="images/m10.jpg" alt="" class="small">
<img src="images/m9.png" alt="" class="big">
</a>
</li>
<li>
<a href="#">
<img src="images/m12.jpg" alt="" class="small">
<img src="images/m11.png" alt="" class="big">
</a>
</li>
<li>
<a href="#">
<img src="images/m14.jpg" alt="" class="small">
<img src="images/m13.png" alt="" class="big">
</a>
</li>
</ul>
</div>
<script>
$(function() {
$("li").mouseenter(function() {
$(this).stop().animate({
width: 224
}, 200).find(".small").stop().fadeOut().siblings(".big").stop().fadeIn();
$(this).siblings("li").stop().animate({
width: 69
}, 200).find(".big").stop().fadeOut().siblings(".small").stop().fadeIn();
});
});
</script>
</body>
</html>
最终效果: