我想构建一个内容滑块,该滑块左右两侧有一个箭头进行导航。我想要设置滑块的位置+ 100px(当你点击右键)和-100像素(当你点击左键时)。此功能起作用。Jquery滑块控件
但是,如果出现错误,我想禁止它在达到某个x位置值时移动。所以当我的内容到达结尾时,它必须停止,以便用户只能回溯。
希望你能帮助我,因为我找不到它。
CSS
#container{
width: 500px;
height: 150px;
background:#CDFAA8;
overflow:hidden;
position:absolute;
left: 13px;
}
#slider{
width: 200px;
height: 150px;
background:#063;
position:absolute;
left: 0px;
}
#block1{
width: 100px;
height: 150px;
background:#067;
float: left;
}
#block2{
width: 100px;
height: 150px;
background:#079;
float: left;
}
#move_right{
height: 150px;
width: 20px;
background: #3f3f3f;
position: absolute;
right:0px;
z-index: 200;
opacity: 0.2;
}
#move_left{
height: 150px;
width: 20px;
background: #3f3f3f;
position: absolute;
left:0px;
z-index: 200;
opacity: 0.2;
}
HTML
<div id="container">
<div id="move_left"><button id="right">«</button></div><div id="move_right"><br><br><button id="left">»</button></div>
<div id="slider">
<div id="block1"></div>
<div id="block2"></div>
</div>
</div>
的Java
$("#right").click(function() {
$("#slider").animate({
"left": "+=100px"
}, "slow");
});
$("#left").click(function() {
$("#slider").animate({
"left": "-=100px"
}, "slow");
});
好吧(我从我的假期回来),我正在检查脚本。除了一件事以外,其中的一件作品......当#slider比它停止工作的容器更宽时 – Odee 2012-03-11 13:54:45