Forum Moderators: not2easy

Message Too Old, No Replies

making divs relatively absolute?

         

emomilk

8:48 am on Aug 3, 2004 (gmt 0)

10+ Year Member



Not sure if this is a weird question or not..

Does anyone know a way to have div's absolute but to the top left of their parent object (i.e. <div><div></div></div>) rather than the page?

My problem is I need to have overlapping divs that can be clicked between (one is visible while the others are all hidden) that need to be absolutely placed (else they offset the other content). However, these divs are all inside a div that changes position depending on the browser width (it's centered).

Anyone have any ideas?

cheers..

mipapage

9:05 am on Aug 3, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member




<div id="a">

<div id="b">
</div>

<div id="c">
</div>

</div>

#a {position:relative} (or absolute)
#b {position:absolute;top:whatever;left:whatever} (or bottom:whatever;right:whatever}
#c {position:absolute;top:whatever;left:whatever} (or bottom:whatever;right:whatever}


An absolutely positioned element will position itself absolutely based on the 'nearest' positioned parent element. If there is no positioned parent element it will use the viewport.

So in this case, div.id=a is a positioned wrapper, and #b and #c can be absolutely positioned realtive to a.

Is this what you were after?

Bonusbana

11:34 am on Aug 3, 2004 (gmt 0)

10+ Year Member



Doesnt margin-top and margin-left work for you?

emomilk

4:30 pm on Aug 3, 2004 (gmt 0)

10+ Year Member



cheers guys.

i'm not exactly sure why that wasn't working before. Now the problem is that the parent frame doesn't handle the overflow of the inner div's.

bah. i'll sort it out eventually..