我在小格子里面有一个大图像。在该格内有4个箭头来控制运动,右,下,左和上。箭头用于在较小的div内移动图像。滚动div内的大图像
这是JS代码
$('.slide-right').click(function() {
$('.inner img').animate({ "right": "+=50px" }, "slow");
});
$('.slide-bottom').click(function() {
$('.inner img').animate({ "bottom": "+=50px" }, "slow");
});
$('.slide-left').click(function() {
$('.inner img').animate({ "left": "+=50px" }, "slow");
});
$('.slide-top').click(function() {
$('.inner img').animate({ "top": "+=50px" }, "slow");
});
这是HTML:
<div id="content">
<div class="image-box">
<div class="inner"><img alt="" src="http://s15.postimg.org/5phzr2off/img.jpg" id="image" /></div>
<div id="arrow-up"><a href="javascript:void(0);" class="slide-top"><img alt="" src="http://s24.postimg.org/gr2uv14d1/arrow_top.png" /></a></div>
<div id="arrow-right"><a href="javascript:void(0);" class="slide-right"><img alt="" src="http://s24.postimg.org/ruda95avp/arrow_right.png" /></a></div>
<div id="arrow-bottom"><a href="javascript:void(0);" class="slide-bottom"><img alt="" src="http://s10.postimg.org/n8hv0166x/arrow_bottom.png" /></a></div>
<div id="arrow-left"><a href="javascript:void(0);" class="slide-left"><img alt="" src="http://s2.postimg.org/qrpm662u1/arrow_left.png" /></a></div>
</div>
</div>
演示:http://jsfiddle.net/john_bale96/C26rV/
我想使动画停止时的边缘图像已达到。有人能给我一些关于如何做到这一点的线索吗?
不是完整的解决方案,但它可以帮助[小提琴](http://jsfiddle.net/f00bar/C26rV/3/) – Stphane