By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,879 Members | 1,809 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,879 IT Pros & Developers. It's quick & easy.

div position problem

roula
P: 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
Share this Question
Share on Google+
2 Replies


drhowarddrfine
Expert 5K+
P: 7,435
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
P: 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.