Skip to content

Allows you to accurately obtain an element’s em value in pixels using JavaScript.

Notifications You must be signed in to change notification settings

tysonmatanich/getEmPixels

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

GetEmPixels

Allows you to accurately obtain an element’s em value in pixels using JavaScript. No more blindly dividing by hard-coded values.

Demo: http://www.matanich.com/examples/get-em-pixels/

Article: http://www.matanich.com/2013/06/24/em-values-javascript/

The basics

GetEmPixels is simple to use and has only one function.

// Get the em or rem value of the documentElement
getEmPixels();

// Get the em value of the #footer element
getEmPixels(document.getElementById('footer'));

Size and delivery

Currently, getEmPixels.js compresses to around 481 bytes (~0.47 KB) after minify. To minify, you might try these online tools: [Microsoft Ajax Minifier]:(http://ajaxmin.codeplex.com/), [Uglify]:(http://marijnhaverbeke.nl/uglifyjs), [Yahoo Compressor]:(http://refresh-sf.com/yui/), or Closure Compiler.

Support

GetEmPixels supports a broad range of browsers and devices (there are currently no known unsupported browsers).

About

Allows you to accurately obtain an element’s em value in pixels using JavaScript.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 3

  •  
  •  
  •