···<html lang="en">
<head>
<meta charset="UTF-8">
<title></title>
<style>
{margin: 0; padding:0; list-style: none;}
#ul1{
width: 520px;
height: 280px;
position: absolute;
top:50%;
left:50%;
margin: -180px 0 0 -260px;
overflow: hidden;
}
#ul1 li{
width: 520px;
height: 280px;
position: absolute;
left: 0;
top:0;
}
</style>
<script src="js/jquery-1.7.2.js"></script>
</head>
<body>
<ul id="ul1">
<li>
![](images/0.jpg)
<li>
![](images/1.jpg)
<li>
![](images/2.jpg)
<li>
![](images/3.jpg)
<li>
![](images/4.jpg)
</ul>
</body>
<script>
$(()=>{
const W=30;
//js設(shè)置ul的寬度
$('ul').css({width:520+W($('ul li').length-1)});
//大于第0個的li的定位
$('ul li:gt(0)').each((i,e)=>{
$(e).css({left:520+Wi});
});
//li移入的時候
$('ul li').mouseenter(function (i,e) {
var iNow=$(this).index();//每個li的索引
$('ul li').each((i,e)=>{
if (i<=iNow){//左邊
$(e).stop().animate({'left':iW});
}else{ //右邊
$(e).stop().animate({'left':520+(i-1)*W});
}
});
})
})
</script>
</html>···