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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Div Top & Left question

Status
Not open for further replies.

booeyOH

Programmer
May 30, 2007
48
0
0
US
Hello,
Ok, if I have a relative div ("reldiv") at x,y coordinates 100,100 of the overall viewport. And inside "reldiv" I have an absolute div ("relabsdiv"). And I want to move "relabsdiv" to point 0,0 of the overall viewport, it only moves it to point 0,0 of the relative div. I understand this is the way it is supposed to work, but I was wondering if there was a way to "escape" the "relabsdiv" div out "reldiv" after the fact.

Thanks,
Booey
 
Why put it inside a div if you don't want it to be inside the div?

If you want the second div to be 0,0 of the view port, then put it outside your outer div, and just position it there.





----------------------------------
Ignorance is not necessarily Bliss, case in point:
Unknown has caused an Unknown Error on Unknown and must be shutdown to prevent damage to Unknown.
 
The short of it is, that I can't put it outside the div.

The long of it is, that it gets created INSIDE the div by an ajax call AFTER the original page (that holds the "reldiv") gets loaded. So it would be very complicated to do it that way.

So back to the basic question.

Is there a way to move a div from outside of a relative div?

Feel free to critique my question, but only after supplying a useful answer.

Thanks.

Booey
 
2. My answer was useful. Its against all logic to want an element inside another element to be positioned somewhere outside the parent element.

If you put a book inside a box, you would not expect that book to be placed in a bookshelf 2 feet from the box would you?

However if you must do that use position:fixed instead of absolute in your inner div. However IE6 does not support it. IE7 does.

Another side effect is that it will not scroll with the rest of the content, it will always be at that positioned if that is what you want.




----------------------------------
Ignorance is not necessarily Bliss, case in point:
Unknown has caused an Unknown Error on Unknown and must be shutdown to prevent damage to Unknown.
 
You can also use negative values with absolute positioning. If you (in your example) give your absolutely positioned element top and left values of -100 it would appear where you want it. Provided that relative box has overflow set to visible.

___________________________________________________________
[small]Do something about world cancer today: Comprehensive cancer control information at PACT[/small]
 
Given you're using JS for your AJAX, why not get the AJAX callback to do as vacunita suggested, and write the "abs" DIV where you want it, outside of the "rel" DIV?

I don't see how hard it can be to change the target...

Dan



Coedit Limited - Delivering standards compliant, accessible web solutions

[tt]Dan's Page [blue]@[/blue] Code Couch
[/tt]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top