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.
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.
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?