我想添加两个箭头到“箱子”divs(下面)的两侧循环3个div。下一个/上一个箭头循环通过div
工作的jsfiddle:https://jsfiddle.net/HBHcC/11/
有人可以帮助我?
HTML:
<div class="container">
<div class="boxes">
<div class="one box">
</div>
<div class="two box">
</div>
<div class="three box">
</div>
</div>
</div>
CSS:
.container{
width:100px;
height:100px;
overflow:hidden;
position:relative;
}
.box {
display:inline-block;
float: left;
width: 100px;
height: 100px;
}
.one{
background-color:green;
}
.two{
background-color:red;
}
.three{
background-color:blue;
}
.boxes{
width:400px;
}
JS:
$(document).ready(function(){
$('.box').on("click", function() {
// Is this the last div, or is there a next one?
if ($(this).next().length) {
var animSpeed = 200; // Make this 0 for an instant change
$('.boxes').animate({marginLeft : "-=100"}, animSpeed);
}
});
});
您好。这个问题的格式不适用于SO。请阅读发布指南:http://stackoverflow.com/help/how-to-ask – grill
我不认为它是“不合适的”,但它确实表现出一点懒惰。 – Roberto