Hi all.
As i understand it, if i set a div position to ‘position: Relative;’, it will offset that div from a div surrounding it/parent div. However it works for the first div that i put in my main, centred content div. But when i insert a second small div, in the content div, it seems to offset correctly on the X axis, but on the y axis, it offsets from the previously made (other small one) div, rather than the main content div it is in. Why is this happening? Is it supposed to?
Below is some code demonstrating this.
[code]
<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Transitional//EN” “http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd”>
<html mlns=”http://www.w3.org/1999/xhtml>
<head>
<meta http-equiv=”Content-Type” content=”text/html; charset=utf-8″ />
</head>
<style type=”text/css”>
<!–
body
{
text-align: center;
}
#apDiv2,
#apDiv1 {
position: relative;
width:400px;
height:115px;
left: 0px;
border: solid;
}
#apDiv2
{
left: 405px;
}
#index_Main
{
width: 810px ;
height: 1000px;
margin-left: auto ;
margin-right: auto ;
margin-top: 1px;
margin-bottom: 1px;
border: solid;
text-align: left;
}
–>
</style>
<body>
<div id=”index_Main”>
<div id=”apDiv1>
</div>
<div id=”apDiv2>
</div>
</div>
</body>
</html>
As you can see, apDiv2, positions itself relative to the bottom of apDiv1, which is wrong. I want it to be totaly inline with apDiv1, and as far as i can see, and my logic dictates, the above code should work, but CSS so far seems to be a bit mucked up.
I would greatly appreciate it if anyone could help.
Cheers.