我在小格子裏面有一個大圖像。在該格內有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