SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Evangelist
    Join Date
    Jan 2005
    Posts
    425
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    div positioning question

    I have 2 divs both hidden and absolute and sitting inside a relative div.

    Both divs (the absolote ones) are hidden until a javscript event triggers them to be displayed and alters their content. The second absokute div I want to sit flush on the right side of the first absolute div with top borders lined up. However in javascript when I do:
    document.getElementById("div_1").style.width or
    document.getElementById("div_1").style.right - nothing is returned, so I can not position the second div.

    I think this may be because the first div width is always different - depending on teh content it holds and doesn't have a defined style="width:###" attribute.

    Can somebody help, I am fairly new to divs and CSS.

  2. #2
    SitePoint Wizard bronze trophy Tyssen's Avatar
    Join Date
    Oct 2005
    Location
    Brisbane, QLD
    Posts
    4,067
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Why do they need to be position: absolute? Doing that causes them to shrink to fit their content.

  3. #3
    SitePoint Evangelist
    Join Date
    Jan 2005
    Posts
    425
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    good question...it was suggested to me as teh div code is located within a table and is required to span the width of the table it's code is located in - and thus doig it absolute so it doesn't follow the document structure.

    So I have:
    Code:
    <td>
    <div style="position: relative;float: left;display: hidden;">
    <div style="display: hidden;float:left;background-color:#000000;color:#000000;position:absolute;" id="qs" nowrap="true"></div>
    <div style="display: hidden;float: left;background-color:#000000;color:#000000;position:absolute;" id="sr"></div> </div>
    </td>
    the div "sr" i I want to programatically place next to (right side) the div qs (which size changes depending on the content of it - which is generated by ajax).


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
  •