1 回答
TA贡献1830条经验 获得超3个赞
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<script type="text/javascript" src="jquery-3.2.1.js"></script>
<title>轮播特效</title>
<style>
.box1{
width:200px;
height:300px;
border:1px dotted black;
background: #aaa;
overflow: hidden;
}
.item{
width: 198px;
height:200px;
border:1px solid red;
float:left;
background:#ff00cc;
}
.cont{
width:1000px;
position:relative;
}
</style>
</head>
<body>
<div class="box1">
<div class="cont">
<div class="item" index="0">0000</div>
<div class="item" index="1">1111</div>
<div class="item" index="2">2222</div>
<div class="item" index="3">3333</div>
<div class="item" index="4">4444</div>
</div>
</div>
</body>
<script type="text/javascript">
var index=0;
$(".box1").on("click",function(){
var curr=(index++)%5;
console.log(1111);
$(".cont").animate({left:"-200px"},1000,function(){
$(".cont").css("left",0);
$(".item[index="+ curr +"]").appendTo($(".cont"));
});
});
</script>
</html>
- 1 回答
- 0 关注
- 24284 浏览
添加回答
举报