Jump to content

absolute positioning acts like relative


boltonw

Recommended Posts

Hi,The following code acts like relative positioning instead of absolute. The first image is positioned at left:280px; top:560px but the second image is positioned at 0,0 but instead of being positioned at the upper left corner of the page, the image is positioned at the upper left of the first image, just like a relative position. Originally, I did not have the size of the DIV in the code, but it made no difference as well.Thanx,BBBCODE:<body bgcolor="#FFFFFF"> <div id="specials" style="position:absolute; left:280px; top:560px; width:516px; height:29px; z-index:1"> <IMG src="images/daily_specials.jpg" WIDTH="516" HEIGHT="29" BORDER="0" ALT=""> <div id="rueben" style="position:absolute; left:0px; top:0px; width:161px; height:41px; z-index:2"> <IMG src="images/grilled_rueben_btn.jpg" WIDTH="161" HEIGHT="41" BORDER="0" ALT=""></body></html>

Link to comment
Share on other sites

Try closing your div tags:<div id="specials" style="position:absolute; left:280px; top:560px; width:516px; height:29px; z-index:1"><IMG src="images/daily_specials.jpg" WIDTH="516" HEIGHT="29" BORDER="0" ALT=""></div><div id="rueben" style="position:absolute; left:0px; top:0px; width:161px; height:41px; z-index:2"><IMG src="images/grilled_rueben_btn.jpg" WIDTH="161" HEIGHT="41" BORDER="0" ALT=""></div>

Link to comment
Share on other sites

Looks like you didn't use a closing div tag around your images. Are you trying to do this?:

<div style="position: absolute; width: 516px; height: 29px; z-index: 1; left: 280px; top: 560px;" id="specials">   <img alt="" src="images/daily_specials.jpg" width="516" border="0" height="29"></div><div style="left: 0px; top: 0px; width: 161px; height: 41px; z-index: 2; position: absolute;" id="rueben">   <img alt="" src="images/grilled_rueben_btn.jpg" width="161" border="0" height="41"></div>

Link to comment
Share on other sites

By the way, this (positioned relative to the top left corner of the parent) is the expected behaviour for position:absolute if the parent is positioned relatively. position:relative, on the other hand, positions the element relative to where it would be otherwise, if no positioning was applied.P.S. don't forget to validate your code, and a lot of these issues can be easily avoided.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...