Return to Snippet

Revision: 54103
at December 10, 2011 02:29 by bernhardb


Initial Code
function getBgPos(oObj) {
	var aPosXY = false;

	try {
		aPosXY = oObj.css('background-position').replace(/px/g, '').split(' ');
		aPosXY[0] = parseInt(aPosXY[0]);
		aPosXY[1] = parseInt(aPosXY[1]);
	} catch(error) {
		var aPosX = oObj.css("background-position-x").split('px');
		var aPosY = oObj.css("background-position-y").split('px');
		aPosXY = new Array(parseInt(aPosX[0]), parseInt(aPosY[0]));
	}
	return aPosXY;
}

Initial URL
http://blog.appstack.io

Initial Description
Creating sprite buttons often had problems with different browsers.
This is a solution to get background positions in each browser for further manipulation.

Initial Title
Cross Browser CSS sprites (for hovers, clicks, active state change via background position change)

Initial Tags
jquery, background

Initial Language
jQuery