我想用jQuery制作一张动画。我有这样的代码:
$(document).ready(function(){
$(".label").delay(2000).animate({backgroundPositionX:"0px",backgroundPositionY:"30px"},10000,linear);
$(".label").animate({backgroundPositionX: "-70px" ,backgroundPositionY:"30px"},10000,linear);
$(".label").animate({backgroundPositionX: "-140px" ,backgroundPositionY:"30px"},10000,linear);
但是动画不起作用。你知道哪里出问题了吗?
发布于 2013-01-08 23:13:12
此SO question and answer将有所帮助。backgroundPositionX
和backgroundPositionY
是非标准的,并不是在所有浏览器上都能工作。
发布于 2013-01-09 01:35:50
我将我的代码编辑为:
$(document).ready(function () {
$(".label").delay(2000).css({
"backgroundPositionX": "0px",
"backgroundPositionY": "30px"
}, 5000, 'linear');
$(".label").animate({
"backgroundPositionX": "-70px",
"backgroundPositionY": "30px"
}, 5000, 'linear');
$(".label").animate({
"backgroundPositionX": "-140px",
"backgroundPositionY": "30px"
}, 5000, 'linear');
});
而且它适用于Chrome。
发布于 2013-01-08 23:29:06
$(document).ready(function () {
$(".label").delay(2000).animate({
backgroundPositionX: "0px",
backgroundPositionY: "30px"
}, 10000, 'linear');
$(".label").animate({
backgroundPositionX: "-70px",
backgroundPositionY: "30px"
}, 10000, 'linear');
$(".label").animate({
backgroundPositionX: "-140px",
backgroundPositionY: "30px"
}, 10000, 'linear');
});
一个demo
https://stackoverflow.com/questions/14217942
复制相似问题