Skip to content

Instantly share code, notes, and snippets.

@varemenos
Created April 20, 2012 18:32
Show Gist options
  • Save varemenos/2430897 to your computer and use it in GitHub Desktop.
Save varemenos/2430897 to your computer and use it in GitHub Desktop.
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment