PDA

View Full Version : Absolute div and elements won't stay fixed under relative positioned container. Help!



theflyingburito
21 Dec 2009, 08:17 PM
Working on a site using graphics that i built with fireworks cs4. I set up all my elements and content under a parent container div tag positioned relatively with auto margin. All of my elements inside are positioned absolute and should line up with the container tag. However when I expand the browser window all the elements underneath the tableHeader div shift left and the header remains centered. I am trying to keep everything centered under that header. Don't know what I am doing wrong. The url is http://www.tripleahomerepair.com if you maximize the browser window you can see. Also here is the code.

<!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">
<style type="text/css">
td img {display: block;}
#bodyText {
position:absolute;
width:562px;
height:396px;
left: 343px;
top: 417px;
background-color: #F7F7F7;
border: #66CCFF groove;
padding: 10px;
}


#tableHeader {
margin:auto;


}

.style1 {font-family: Geneva, Arial, Helvetica, sans-serif}
#couponBox {
position:absolute;
width:129px;
height:115px;
left: 102px;
top: 426px;
}
#imgBoxA {
position: absolute;
left: 66px;
top: 543px;
width: 273px;
height: 208px;
}
</style>



<script type="text/javascript">
<!--
function MM_swapImgRestore() { //v3.0
var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}
function MM_preloadImages() { //v3.0
var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
var p,i,x; if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
//-->
</script>
<body onload="MM_preloadImages('images/reviews_f2.jpg','images/services_f2.jpg','images/contact_f2.jpg','images/home_f2.jpg')">
<div style="position:relative; margin:auto; zoom: 1;">
<table id="tableHeader" border="0" cellpadding="0" cellspacing="0" width="900">
<!-- fwtable fwsrc="3a.png" fwpage="Page 1" fwbase="triple a header.jpg" fwstyle="Dreamweaver" fwdocid = "977374389" fwnested="0" -->
<tr>
<td><img src="images/spacer.gif" width="384" height="1" border="0" alt="" /></td>
<td><img src="images/spacer.gif" width="53" height="1" border="0" alt="" /></td>
<td><img src="images/spacer.gif" width="40" height="1" border="0" alt="" /></td>
<td><img src="images/spacer.gif" width="77" height="1" border="0" alt="" /></td>
<td><img src="images/spacer.gif" width="40" height="1" border="0" alt="" /></td>
<td><img src="images/spacer.gif" width="89" height="1" border="0" alt="" /></td>
<td><img src="images/spacer.gif" width="38" height="1" border="0" alt="" /></td>
<td><img src="images/spacer.gif" width="104" height="1" border="0" alt="" /></td>
<td><img src="images/spacer.gif" width="75" height="1" border="0" alt="" /></td>
<td><img src="images/spacer.gif" width="1" height="1" border="0" alt="" /></td>
</tr>
<tr>
<td colspan="9"><img name="tripleaheader_r1_c1" src="images/triple%20a%20header_r1_c1.jpg" width="900" height="196" border="0" id="tripleaheader_r1_c1" alt="" /></td>
<td><img src="images/spacer.gif" width="1" height="196" border="0" alt="" /></td>
</tr>
<tr>
<td colspan="5"><img name="tripleaheader_r2_c1" src="images/triple%20a%20header_r2_c1.jpg" width="594" height="8" border="0" id="tripleaheader_r2_c1" alt="" /></td>
<td rowspan="4"><a href="../reviews.htm" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('reviews','','images/reviews_f2.jpg',1);"><img name="reviews" src="images/reviews.jpg" width="89" height="37" border="0" id="reviews" alt="" /></a></td>
<td colspan="3"><img name="tripleaheader_r2_c7" src="images/triple%20a%20header_r2_c7.jpg" width="217" height="8" border="0" id="tripleaheader_r2_c7" alt="" /></td>
<td><img src="images/spacer.gif" width="1" height="8" border="0" alt="" /></td>
</tr>
<tr>
<td colspan="3"><img name="tripleaheader_r3_c1" src="images/triple%20a%20header_r3_c1.jpg" width="477" height="2" border="0" id="tripleaheader_r3_c1" alt="" /></td>
<td rowspan="2"><a href="../services.htm" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('services','','images/services_f2.jpg',1);"><img name="services" src="images/services.jpg" width="77" height="19" border="0" id="services" alt="" /></a></td>
<td rowspan="4"><img name="tripleaheader_r3_c5" src="images/triple%20a%20header_r3_c5.jpg" width="40" height="196" border="0" id="tripleaheader_r3_c5" alt="" /></td>
<td rowspan="4"><img name="tripleaheader_r3_c7" src="images/triple%20a%20header_r3_c7.jpg" width="38" height="196" border="0" id="tripleaheader_r3_c7" alt="" /></td>
<td rowspan="2"><a href="../contact.htm" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('contact','','images/contact_f2.jpg',1);"><img name="contact" src="images/contact.jpg" width="104" height="19" border="0" id="contact" alt="" /></a></td>
<td rowspan="4"><img name="tripleaheader_r3_c9" src="images/triple%20a%20header_r3_c9.jpg" width="75" height="196" border="0" id="tripleaheader_r3_c9" alt="" /></td>
<td><img src="images/spacer.gif" width="1" height="2" border="0" alt="" /></td>
</tr>
<tr>
<td rowspan="3"><img name="tripleaheader_r4_c1" src="images/triple%20a%20header_r4_c1.jpg" width="384" height="194" border="0" id="tripleaheader_r4_c1" alt="" /></td>
<td><a href="../index.htm" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('home','','images/home_f2.jpg',1);"><img name="home" src="images/home.jpg" width="53" height="17" border="0" id="home" alt="" /></a></td>
<td rowspan="3"><img name="tripleaheader_r4_c3" src="images/triple%20a%20header_r4_c3.jpg" width="40" height="194" border="0" id="tripleaheader_r4_c3" alt="" /></td>
<td><img src="images/spacer.gif" width="1" height="17" border="0" alt="" /></td>
</tr>
<tr>
<td rowspan="2"><img name="tripleaheader_r5_c2" src="images/triple%20a%20header_r5_c2.jpg" width="53" height="177" border="0" id="tripleaheader_r5_c2" alt="" /></td>
<td rowspan="2"><img name="tripleaheader_r5_c4" src="images/triple%20a%20header_r5_c4.jpg" width="77" height="177" border="0" id="tripleaheader_r5_c4" alt="" /></td>
<td rowspan="2"><img name="tripleaheader_r5_c8" src="images/triple%20a%20header_r5_c8.jpg" width="104" height="177" border="0" id="tripleaheader_r5_c8" alt="" /></td>
<td><img src="images/spacer.gif" width="1" height="10" border="0" alt="" /></td>
</tr>
<tr>
<td><img name="tripleaheader_r6_c6" src="images/triple%20a%20header_r6_c6.jpg" width="89" height="167" border="0" id="tripleaheader_r6_c6" alt="" /></td>
<td><img src="images/spacer.gif" width="1" height="167" border="0" alt="" /></td>
</tr>
</table>
<div id="bodyText">
<p align="center" class="style1">Hey Dad, this is your new website. Right in this box you should come up with a short and sweet intro about your company. This is the front page of your site and it is the first thing your potential customer sees so make it good. Also, I wouldnt list all your services right here, i can add a link in this box to your services. Just write everything down and email it or send it to me and i will add it in!</p>
</div>

<div id="couponBox"> <img name="coupon" src="images/coupon.gif" width="124" height="115" border="0" id="coupon" usemap="#m_coupon" alt="" />
<map name="m_coupon" id="m_coupon">
<area shape="rect" coords="4,-7,128,108" href="../coupon.htm" title="click here for your coupon!" alt="click here for your coupon!" />
</map>
</div>



<img style="position:absolute; border:medium #CCCCCC; left: 55px; top: 625px; width:271; height:236;" src="images/IMG_7042.JPG" width="271" height="236" /><img style="position:absolute; left: 34px; top: 879px; width=909px; height: 31px;" src="images/footer.jpg" width="909" height="43" />
</div>

</body>
</html>