Created
April 20, 2012 18:32
-
-
Save varemenos/2430897 to your computer and use it in GitHub Desktop.
JQuery - 1em to pixels
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment