« Return to Thread: .css() px vs. em
Just as a follow up, here's how I helped Karl on AIM:var num = parseFloat( val );var type = val.slice(-2);num *= 1.2;$(...).css( "fontSize", num + type );The difference in the reported fontSize is something we're looking at.--JohnOn 1/6/07, Karl Swedberg <karl@...> wrote:Hi folks,I'm trying to get the font size of some text using the .css() method, butI'm running into a problem because Firefox is returning the value in pixelswhile IE6 is returning the value in ems. Is this a bug? Or is it just abrowser difference that we have to account for in our code?Text is inside a div with ID of "container" and I have the followingrelevant CSS:body {font-size: 62.5%;}#container {font-size: 1.2em;}Here is what the browsers return for $('#container').css('fontSize') :Firefox: 12pxIE6: 1.2emActually, it looks to me like IE6 is doing the right thing here, returningthe actual value from the stylesheet rather than a computed value.This is a problem because I want to incrementally increase the font size. Iwas doing that in Firefox by1. getting the font size2. stripping the "px" with parseInt()3. multiplying the remaining number by 1.24. reattaching the "px"5. setting the new font sizeI know that in this case I can simply grab the last two letters of thestring and put them in a variable and attach them back after I do themultiplication. But does anyone have an idea why the difference is there inthe first place, and if it should be there, and if there is a way tonormalize it?Thanks all for your help.--Karl_________________Karl Swedbergwww.englishrules.comwww.learningjquery.com_______________________________________________jQuery mailing listhttp://jquery.com/discuss/_______________________________________________jQuery mailing listhttp://jquery.com/discuss/
« Return to Thread: .css() px vs. em
| Free embeddable forum powered by Nabble | Forum Help |