PDA

View Full Version : Putting an ApDiv inside a Centred DivTag?


whitedragon101
06-18-2009, 12:43 AM
I have a centred div tag called wrapper that contains my page using margin:auto . I want to use AP Divs inside but positioned relative to the wrapper tag not the top left of the browser.

I have copied and pasted a solution (code 1) someone posted on a previous thread but this only works by manually entering the left and top margins. As soon as you return to design view and drag the ApDiv around to where you want it the left and top numbers are automatically written to the css file making the box not relative any more (code 2).

Surely Dreamweaver can move an ApDiv inside a centred DivTag.... Can't it??...Help???:confused:

CODE 1
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>testing divs</title>
<style type="text/css">
<!--
body {
text-align : center ;
min-width:700px;
}
#my_wrapper{
height: 700px;
width: 760px;
margin: auto;
background-color: #3F9;
}

#apDiv1 {
position:absolute;
margin-left:140px;
margin-top:80px;
width:155px;
height:230px;
z-index:1;
background-color: #F66;
}


-->
</style>
</head>

<body>

<div id="my_wrapper">
<div id="apDiv1">hello</div>
</div>

</body>
</html>
CODE 2

#apDiv1 {
position:absolute;
margin-left:140px;
margin-top:80px;
width:155px;
height:230px;
z-index:1;
background-color: #F66;
left: 291px;
top: 130px;
}

edbr
06-18-2009, 01:49 AM
just put the apdiv inside the wrapper. absolute divs will take its reference point from its container if not in a div it uses body as its reference if you have
<div id='#my_wrapper'>
<div id='#apDiv1'> absolute </div>
</div>

DWcourse
06-18-2009, 02:10 AM
The ap div will position itself relative to the my_wrapper div only if the #my_wrapper style has positioning applied. So set the positioning of #my_wrapper to relative (without any top, bottom, left or right properties).

whitedragon101
06-20-2009, 12:51 PM
Thanks guys works like a charm :)