468,316 Members | 2,078 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,316 developers. It's quick & easy.

div position problem

roula
18
Hi,

I have this code of some divs, and I am trying to put a transparent image in div #transp to cover a certain area of the parent div #main (in order to make an image map of the background image of #main)

i'm trying to position #transp to be in the location i want, but i'm not able to.

doesn't position:relative means the div position is relative to its parent?

here is the code, and you can read some comments inside the last div to clarify more...

Expand|Select|Wrap|Line Numbers
  1. <div id="main" style="width:800px;height:800px;margin:0 auto;background: url('/img/bge.jpg') center no-repeat;">
  2. <div id="dhtmlgoodies_scrolldiv" style="position:relative;top:255px;left:257px;">
  3. <div id="scrolldiv_parentContainer">
  4. <div id="scrolldiv_content">
  5. (my contents here)
  6. </div>
  7. </div>
  8. </div>
  9. <div id="transp" style="position:relative;width:257px;height:181px;top:352px;left:0px;background-color:#ff0000;">
  10. <img src="img/spacer.gif" width="257" height="181" />
  11. (in this div there is the transparent image, i'm just coloring it red now to see its position)
  12. (this div is supposed to be in position top 352 and left 0, the left is really 0 relative to the parent that has the background, but the top is more than 352, i dont know why... should i use -minus to position the div where i want?)
  13. </div>
if this is not clear i can post a link to the page.

thank you for your help.
Mar 12 '07 #1
2 4007
drhowarddrfine
7,435 Expert 4TB
doesn't position:relative means the div position is relative to its parent?
Relative to the first "positioned parent". So set the parent of that div to "position:relative" also.
Mar 12 '07 #2
roula
18
Relative to the first "positioned parent". So set the parent of that div to "position:relative" also.
thanks for the tip, i set #main to relative position, and the other divs to absolute position, it's good now
Mar 13 '07 #3

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

1 post views Thread by Falc2199 | last post: by
5 posts views Thread by CMAR | last post: by
3 posts views Thread by akunamatata | last post: by
5 posts views Thread by Roderik | last post: by
5 posts views Thread by DL | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.