View Full Version : Getting font size

04-10-2003, 11:05 AM
I have a page, which gets its font size from a CSS file. In this file, it's set for 80%. I'm creating a side menu, which is going great so far, except that I want it to have variable width and height according to the font size set in the browser.

I.E. If you set the font size in Explorer to 'Large', the menu's should be larger to fit the font in. The same goes for small. Since the menu itself was, by origin, 100% static with a width and height that could not be changed, this will take some effort in going through the code.

If I can get the correct font size (or height & width in pixels), I can complete the menu :) Is there any function built within JavaScript which can do such a thing or, of not, is there a script available that does a thing like that?

Thx in advance!

04-10-2003, 11:46 AM
You can express menu size in ems. em is measurement relative to font-size.

04-10-2003, 11:54 AM
But how? If I simply change the 'px' to 'em', things get huuuge. If I then, logically, set all sizes to 1 or 2, the entire menu goes bazerk :P

I have 2 JavaScript files:
1. Holds all 'real' programming for the menu, including 'px'
2. Holds all variables and menu structure (items and submenu's)

I change px in file 1 to em
I change sizes to 1 or 2 in file 2

04-10-2003, 11:57 AM
em is based on the size of an "m" character at the contextual font size. So, if your font size is "1em" this maps to roughly 13 pixels.