|
-
May 10th, 2002, 12:39 AM
#1
Thread Starter
Addicted Member
Elegant ways of determining text height?
I need to determine, myself, whether a div (with a fixed height and fixed width) containing a bunch of text is to get a scrollbar or not. The scrollbar you get when you set 'scrolling: auto' is too ugly for this particular application. (The plan is to simulate a scrollbar using JavaScript) Trouble is there doesn't appear to be a way that you can determine whether this target div needs a scrollbar or not, right?
The solution, I think, is to create an off-screen window that contains a div that is the same fixed width as my target div, but allow it to grow taller. Then fill it with the same text (same font, size and everything) that the target div is going to get and measure it's height. If the height is taller than the height of my target div, I know I'll need to put scroll bars on my target div. The overall height of the off-screen div will also be useful for figuring out the placement of the thumb scroll.
The above solution isn't what I'd consider elegant, but it will probably be functional and probably won't present too many problems after the initial tuning. Any other better ideas come to mind?
cudabean
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|