|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
I am trying to run a javascript that constructs a menu but must use absolute positioning. I can put the menu correctly where I want it by setting parameters of left and top from origin. However... this doesn't work too well for a page consisting of 800px tables centered for looking good in any resolution 800x600 and up. So I was wondering if it is possible to use absolute positioning and define an origin using anchor tags or something like that. Any help please?
|
|
#2
|
||||
|
||||
|
You probably have a div or something defining your main content area, right? Like:
PHP Code:
Absolute positioning is relative to the last positioned element, with its "last resort" being the main body of the document. So, you can position your main content area without really moving it by using realtive psoitioning--which means relative to where it would normally be: PHP Code:
The "position: relative; top: 0px; left: 0px;" means that it will be moved 0px from teh top and 0px from the left of where it would normally be placed. Now, you can put your absolutely positioned element (in my example, a div) inside your main content div, and it will be absolutely positioned INSIDE the div, relative to THAT position, as opposed to the main window. PHP Code:
I hope that makes sense. Maybe others can explain it more clearly.
__________________
Proud member of the T.S.N.B.U.F.L (tables should not be used for layout) alliance. "Only use elements for their intended purpose. You wouldn't try to make coffee with a telephone, would you?" -Me |
|
#3
|
||||
|
||||
|
Absolute positioned (AP) elements are referenced to their nearest positioned ancestor. If your js is writing th AP element, I'm guessing you should have it inline so that it is written as a child of the desired container. Alternatively, write the menu directly in html with {display:none;}, using js to toggle the display property.
I say I'm guessing because I won't use javascript or any plugin (eg. Flash) for basic functionality, so I have no first-hand knowledge. cheers, gary
__________________
There are those who manage to build a web site without knowing what they're doing; thereby proving to themselves they do, indeed, know what they're doing. My html and css workshop, demos and tutorials. Ask a better question, get a better answer. |
![]() |
| Viewing: Dev Shed Forums > Web Design > CSS Help > position:absolute relative to user-defined origin? |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|