Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Positioning Question

Status
Not open for further replies.

booeyOH

Programmer
May 30, 2007
48
US
Hello,
Quick question, not sure if it will make sense, but here goes.

I recently learned that if you aboslutely position an element inside another positioned element that has "overflow:auto", it will position it relative to that element (please see
So my question is, can you force an element into aboslute positioning to the whole window regardless of what element it is inside of.

If I am asking the wrong thing, or this doesn't make sense, please let me know.

Thanks
Bryan
 
w3c said:
An element with position: absolute is positioned at the specified coordinates relative to its containing block. The element's position is specified with the "left", "top", "right", and "bottom" properties

So the answer is no.
If you want it absolutely positioned in the page, do not put it inside another positioned element.

Greg
"Personally, I am always ready to learn, although I do not always like being taught." - Winston Churchill
 
Ok, that makes sense, so my next question would be if I am building stuff on the fly, using ajax (xajax to be specific), sometimes I don't have a choice to put an element outside of another positioned element because I am "working" inside a positioned element. Is there a way to create a new div and somehow tell the document to see it as "outside" the div that it is created in. After typing this it sounds a lot like my other question, so if it is, feel free to tell me so.

Thanks,
Bryan
 
No, it is impossible. I suggest you do not put your elements inside the current element but put them in a completely separate container that is the child of the body element. This is how most of the lightboxes work and it seems that you would want something similar as well.

As another option of positioning relative to the viewport, you can use fixed positioning. That will be relative to the viewport (browser window), meaning that it will also stay in the same position regardless of scrolling. IE6 however does not support fixed position.

___________________________________________________________
[small]Do something about world cancer today: PACT[/small]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top