PDA

View Full Version : Help with DIV layer menu position when centered



imanta
07-11-2005, 06:14 PM
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:


<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:


<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!

Twey
07-11-2005, 08:06 PM
Use relative positioning.
(0,0) is the parent's top left corner.

imanta
07-11-2005, 09:13 PM
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.

Twey
07-12-2005, 06:54 PM
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.