Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    New to the CF scene
    Join Date
    Apr 2003
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Getting font size

    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!

  • #2
    New Coder
    Join Date
    Mar 2003
    Location
    Somewhere far beyond
    Posts
    99
    Thanks
    0
    Thanked 0 Times in 0 Posts
    You can express menu size in ems. em is measurement relative to font-size.
    WBR, Weirdan.

  • #3
    New to the CF scene
    Join Date
    Apr 2003
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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

  • #4
    Senior Coder
    Join Date
    Jun 2002
    Location
    near Oswestry
    Posts
    4,508
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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.
    "Why bother with accessibility? ... Because deep down you know that the web is attractive to people who aren't exactly like you." - Joe Clark


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •