我在这里做一个wesbsite:
http://www.benjaminpotter.org/portfolio2/
看看加载启动,它看起来很好,但不是在Firefox中.你知道为什么在jquery中制作动画的背景位置在Firefox中不起作用吗?看看附加到它的脚本叫做animate here.
解决方法
正如dzejkej所指出的,背景位置的单独值不是标准的一部分,并且不受Firefox支持.如
jQuery
animate()
page所述:
All animated properties should be animated to a single numeric value
这意味着背景位置不合格,因为它需要两个值,x pos和y pos.
您将不得不使用动画插件.不幸的是,目前jQuery插件网站已关闭,所以我在这里提供了一个适用于Firefox的版本:
/** jquery.bgpos.js * @author Alexander Farkas * v. 1.02 */ (function($) { $.extend($.fx.step,{ backgroundPosition: function(fx) { if (fx.state === 0 && typeof fx.end == 'string') { var start = $.curCSS(fx.elem,'backgroundPosition'); start = toArray(start); fx.start = [start[0],start[2]]; var end = toArray(fx.end); fx.end = [end[0],end[2]]; fx.unit = [end[1],end[3]]; } var NowPosX = []; NowPosX[0] = ((fx.end[0] - fx.start[0]) * fx.pos) + fx.start[0] + fx.unit[0]; NowPosX[1] = ((fx.end[1] - fx.start[1]) * fx.pos) + fx.start[1] + fx.unit[1]; fx.elem.style.backgroundPosition = NowPosX[0]+' '+NowPosX[1]; function toArray(strg){ strg = strg.replace(/left|top/g,'0px'); strg = strg.replace(/right|bottom/g,'100%'); strg = strg.replace(/([0-9\.]+)(\s|\)|$)/g,"$1px$2"); var res = strg.match(/(-?[0-9\.]+)(px|\%|em|pt)\s(-?[0-9\.]+)(px|\%|em|pt)/); return [parseFloat(res[1],10),res[2],parseFloat(res[3],res[4]]; } } }); })(jQuery);
原文地址:https://www.jb51.cc/jquery/181219.html
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。