varemenos
4/20/2012 - 6:32 PM

JQuery - 1em to pixels

JQuery - 1em to pixels

function em2pxl(){
	// how many pixels in 1em
	var div = $('<div style="width: 1em;"></div>').appendTo('body');
	var em = div.width();
	div.remove();
	// console.log('1em = ' + em + 'pixels.');
	return em;
}

// source: http://forum.jquery.com/topic/how-do-tell-how-many-px-are-in-1em