本文介绍了如何获得firefox中使用jQuery的background-position-y?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
$(elem).css('backgroundPositionY')
编辑:你想要 background-position- [x,y]
支持。 (使用投票功能,而不是评论,除非你有先见之明添加)。 Bug自2010年以来(3年)开放,所以不要屏住呼吸。 :)
解决方案
var backgroundPos = $(elem).css('backgroundPosition') 。分裂( );
//现在包含一个数组,如[0%,50px]
var xPos = backgroundPos [0],
yPos = backgroundPos [1];
$(elem).css('backgroundPositionY')
does it on chrome, ie, and safari, but not Firefox (nor Opera I believe). You'd think jQuery would have a polyfill but it doesn't, as of 1.5. How can I easily get the background Y position for e.g. background animations (for e.g. parallax)?
EDIT: Tell Mozilla you want background-position-[x,y]
support. (use the "vote" feature, not comment, unless you have something prescient to add). Bug has been open since 2010 tho (3 years now) so don't hold your breath for a fix. :)
解决方案
var backgroundPos = $(elem).css('backgroundPosition').split(" ");
//now contains an array like ["0%", "50px"]
var xPos = backgroundPos[0],
yPos = backgroundPos[1];
这篇关于如何获得firefox中使用jQuery的background-position-y?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!