SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Member
    Join Date
    Nov 2003
    Location
    New York
    Posts
    2
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Determining Font Size

    I am building a DHTML widget that replaces the standard select box of a form. I've got things working pretty well except for one thing - how to determine the appropriate size of the dropdown? Right now, someone should be able to enter a size = 5 and if the font size is a particular size, I can be pretty sure that the dropdown will only show 5 elements before it starts scrolling. However, if the font size is larger or smaller than I expect, the scrolling area will show much more or much less than I want it to display. Is there a method I can use to determine the current font size in relation to the screen and then appropriately render a dropdown that is the correct size? I have a feeling there is something pretty basic that I am missing and I can't quite seem to figure out what it is.

    Thanks in advance,

    Alex

  2. #2
    The doctor is in... silver trophy MarcusJT's Avatar
    Join Date
    Jan 2002
    Location
    London
    Posts
    3,509
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    How about writing a character of maximum height (like an "L") to a SPAN, then getting the SPAN's .innerHeight and using that in your calculations?
    MarcusJT
    - former ASP web developer / former SPF "ASP Guru"
    - *very* old blog with some useful ASP code

    - Please think, Google, and search these forums before posting!

  3. #3
    SitePoint Member
    Join Date
    Nov 2003
    Location
    New York
    Posts
    2
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Good idea. I had not thought of that. As a hack, I basically set the line-height for every A in my list (I set every line item to an A to properly display). Then I check the line height and multiply by the number of items that I want shown. It seems to work pretty well so far. However, your idea sounds like it might be more generalized and won't require the line-height to be set.

    Thanks!

    Alex

    Quote Originally Posted by M@rco
    How about writing a character of maximum height (like an "L") to a SPAN, then getting the SPAN's .innerHeight and using that in your calculations?

  4. #4
    The doctor is in... silver trophy MarcusJT's Avatar
    Join Date
    Jan 2002
    Location
    London
    Posts
    3,509
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    MarcusJT
    - former ASP web developer / former SPF "ASP Guru"
    - *very* old blog with some useful ASP code

    - Please think, Google, and search these forums before posting!


Bookmarks

Posting Permissions

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