Klaus Hartl wrote:
  > Couldn't you add an element as direct child to the body, for which you
> define:
> 
> position: absolut;
> visibility: hidden;
> height: 1em;
> font-size: 100% !important;
> 
> Then you can just poll the height of that element, e.g. the offsetHeight 
> and get the current pixel value. That would even work if the default 
> size has been changed.
> 
> And it would not only work for the body element, it should work 
> whereever you append that element. The jqem plugin works in a similiar 
> way and I think I have seen something like that somewhere else already, 
> maybe in YUI.

I've run into this before, and came up with pretty much the same 
solution as Klaus:

http://jquery.lukelutman.com/plugins/px/jquery.px.js

which you can call like so:

$('#example').px('font-size');

One known bug is that it won't work for elements that don't accept 
content, like <img /> or <input />.

Cheers,
Luke

Reply via email to