<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
<script src="jquery-3.6.0.js" type="text/javascript" charset="utf-8"></script>
</head>
<body>
<style>
* {
margin: 0;
padding: 0;
}
.swiper {
width: 800px;
height: 600px;
border: 1px solid #000;
margin: 50px auto;
overflow: hidden;
position: relative;
}
.container {
width: 4000px;
white-space: nowrap;
font-size: 0;
position: absolute;
}
img {
width: 800px;
height: 600px;
}
</style>
<div class="swiper">
<div class="container">
<img src="imgs/1.png" alt="">
<img src="imgs/2.png" alt="">
<img src="imgs/3.png" alt="">
<img src="imgs/4.png" alt="">
<img src="imgs/5.png" alt="">
<img src="imgs/1.png" alt="">
</div>
</div>
<script>
$(function() {
setInterval(function(){
if($('.container').position().left>-3200){
$(".container").animate({
left: "+=-800"
}, 2000)
}else{
$(".container").animate({
left: "+=4000"
}, 1)
}
},2000)
})
</script>
</body>
</html>
“相关推荐”对你有帮助么?
-
非常没帮助
-
没帮助
-
一般
-
有帮助
-
非常有帮助
提交