Results 1 to 4 of 4

Thread: Help with DIV layer menu position when centered

  1. #1
    Join Date
    Jul 2005
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Help with DIV layer menu position when centered

    I have a menu/submenu combo that uses DIV layers, JS, and CSS that workd great currently. The problem I have is that it was designed in a way where everything is absolute. Code looks like this:

    Code:
    <div id="platform_menu" style="position:absolute; left:10px; top:82; width:108; height:17; z-index:3; visibility: visible;">
    Content
    </div>
    Then when the person mouseovers the content in the first div it triggers a sub layer which appears at the time same position:

    Code:
    <div id="platform_submenu" style="position:absolute; left:10px; top:99; width:108; height:108; z-index:21; visibility: hidden;"> 
    Submenu
    </div>
    The question is, how do I make this so it can be centered on a screen? Keep in mind I have multiple _menus and submenus so each submeny would have to know the location of their parent.

    Thanks for the help!

  2. #2
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    Use relative positioning.
    (0,0) is the parent's top left corner.
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

  3. #3
    Join Date
    Jul 2005
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    I have been trying to understand this, if I set it to relative, then what it is relative too? How will the submenu know where to show up underneath?

    Thanks.

  4. #4
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    Relative to its position if you didn't specify any positioning attributes. So, if it has no padding or margin, that would be the top-most left-most unoccupied position in its parent.
    Setting position to relative then left to the width of the parent should position it outside the left edge of its parent.
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

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
  •