我想添加兩個箭頭到「箱子」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