absolute div not displaying right

Last post 03-11-2004 12:30 PM by ParrotBoy. 3 replies.

Sort Posts:

  • absolute div not displaying right

    03-10-2004, 9:43 AM
    • Contributor
      2,378 point Contributor
    • ParrotBoy
    • Member since 10-08-2003, 1:56 AM
    • England
    • Posts 484
    I have the following code on my page:


    <div style="width:200px;height:200px;overflow:auto; border:2px solid silver;">

    <!-- Other HTML -->
    <div style="..." Onclick="ShowHideDropDiv()">Drop-Down Title</div>
    <div style="border:1px solid black; height:150px; overflow-y:scroll; display:none; position:absolute;" id="divDropDiv">
    <!-- Loads of checkboxes -->
    </div>

    </div>


    It is trying to emulate the behaviour of a drop-down-menu as much as possible, but allowing users to select multiple options using the checkboxes.

    The problem is that when ShowHideDropDiv makes divDropDiv visible, it does not float nicely above the main div, it stays inside it, causing it to show a scrollbar - not very nicely user friendly!

    How can I fix this, so that divDropDiv floats on top properly?
    Please mark posts as the answer if I was helpful. Thanks!

    Visit my blog
  • Re: absolute div not displaying right

    03-10-2004, 10:21 AM
    • Member
      305 point Member
    • AdEpt
    • Member since 09-24-2002, 2:16 AM
    • Sweden
    • Posts 61
    Its hard to say what the problem is here because it looks correct to me.
    One thing that I can think of is that the text after the checkboxes is too long to you get an vertical scrollbar you can correct chaning the style in divDropDiv too:

    <div style="width:100%;border:1px solid black; height:150px; overflow-y:scroll;overflow-x:hidden; display:block; position:absolute;" id="divDropDiv">
    while (!asleep()) ++sheep;
  • Re: absolute div not displaying right

    03-10-2004, 2:16 PM
    • Member
      67 point Member
    • sirfree1988
    • Member since 03-08-2004, 7:30 PM
    • Woodinville Wa.
    • Posts 13
    you have to add to the style "Z-INDEX: 1;"

    that tells the browser its a overlay
  • Re: absolute div not displaying right

    03-11-2004, 11:43 AM
    • Contributor
      2,378 point Contributor
    • ParrotBoy
    • Member since 10-08-2003, 1:56 AM
    • England
    • Posts 484
    Thats not worked, however, I took out the overflow:auto; bit in the outside div - the content shouldn't be overflowing anyway, and that's fixed it.

    Thanks!
    Please mark posts as the answer if I was helpful. Thanks!

    Visit my blog
Page 1 of 1 (4 items)