jquery.animate背景位置不起作用 [英] jquery.animate background-position doesn't work
本文介绍了jquery.animate背景位置不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试通过动画创建背景位置更改.
但由于某种原因,它无法正常工作.
I'm trying to create a background position change with animation.
but for some reason it's not working.
<script language="javascript" src="http://code.jquery.com/jquery-1.5.min.js"></script>
<div class="moveme" style="height:80px;width:240px;background-image:url('http://www.google.de/intl/en_com/images/srpr/logo1w.png');background-repeat:no-repeat"></div>
<script language="javascript">
$('.moveme').css("background-position","0px 0px").animate({backgroundPosition:"-100px 10px"});
</script>
想法?
推荐答案
jQuery默认不支持此功能.
jQuery doesn't support this on default.
您可以使用如下插件: http://plugins.jquery.com/project /backgroundPosition-Effect
You can use a plug-in like : http://plugins.jquery.com/project/backgroundPosition-Effect
我错了,它可以工作:
$(function() {
$('.moveme').css("backgroundPosition","0px 0px").animate({"backgroundPosition":"-100px 10px"});
});
如果您在地址栏中键入它会起作用,但是看来我无法在jsfiddle上实现此功能,奇怪的是... xD
It works if you type in the address bar, but it seems I can't make this work on jsfiddle, strange... xD
这篇关于jquery.animate背景位置不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文