1
我有一个100%宽,284px高的div,叫做#photoStripe,背景图片宽度为5000px。然后在左侧和右侧的导航按钮上方。这个想法是能够左右平移,通过左右增量动画背景图像。用jQuery增量背景位置动画
我使用的是popular background position plugin,它允许您同时为背景位置的x和y值设置动画。
好吧,背景动画,但它只能做一次。 (不能一次点击)。任何想法?
的jQuery:
$('#photoStripe').css({backgroundPosition:"0 0"});
$('a.moveLeft').click(function(){
$('#photoStripe').stop().animate({backgroundPosition:'-=200px 0'}, {duration:500});
});
$('a.moveRight').click(function(){
$('#photoStripe').stop().animate({backgroundPosition:'+=200px 0'}, {duration:500});
});
CSS:
#photoStripe {
width:100%;
height:286px;
text-align:center;
overflow:hidden;
background:url(../_images/photo_stripe.jpg);
}
谢谢!格雷戈里我把你的代码和增量添加了我的页面上的其他代码,并发现问题。这是因为我正在调用背景位置插件。显然,它不会增量动画,更适合翻转效果,以及任何您在同时对x和y位置进行动画处理的场合。 – inorganik 2011-01-27 16:06:16