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 3 of 3
  1. #1
    wac
    wac is offline
    Regular Coder wac's Avatar
    Join Date
    Sep 2002
    Location
    Cary, North Carolina, USA
    Posts
    359
    Thanks
    2
    Thanked 0 Times in 0 Posts

    setting DHTML list height

    I'm using ul to render a scrollable list (rather than using select) and I'd like to be able to set the list height to to be able to view N items. I've tried using style="height:Nem" which seems to be off by one (close enough), but it doesn't account for things like border/padding/margin height. Is there a way to account for all this up front without the list flickering because it was rendered with one height and I have to run javascript to reset the height to something else???

    P.S. I'm not using a select because it renders ontop of DIVs (yes, I know about wrapping the DIV with an IFRAME) and the border style cannot be set.
    Wayne Christian

  • #2
    Supreme Master coder! _Aerospace_Eng_'s Avatar
    Join Date
    Dec 2004
    Location
    In a place far, far away...
    Posts
    19,291
    Thanks
    2
    Thanked 1,043 Times in 1,019 Posts
    I guess you could do it dynamically
    Code:
    document.getElementById('yourmenu').style.height=document.getElementById('yourmenu').offsetHeight;

  • #3
    wac
    wac is offline
    Regular Coder wac's Avatar
    Join Date
    Sep 2002
    Location
    Cary, North Carolina, USA
    Posts
    359
    Thanks
    2
    Thanked 0 Times in 0 Posts
    I know, I am worried about the list flickering in size as it is rendered, then the height is reset. The style info is not available until after the page is rendered.
    I'll have to just do it and see how bad things are on the different browsers.
    Wayne Christian


  •  

    Posting Permissions

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