473,657 Members | 2,505 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

position:absolu te in a relative container bug

3 New Member
hello , I have an issue positionating some pics I want to anchor to an existing table cell but I cant just place regular position on the cell because the background is fixed height and the set of pics is bigger then fixed space. SO I put them in a position:absolu te div and I gave a position:relati ve to the container td.
This seems to work in IE but in Firefox position is relative to the browser window, not the cell. I need a compatible solution to anchor this vertical set of pics relatively to a specific area of the layout not the general browser window sigh...
Here is the complete html code (the bold code is for what I'm referring to) and also some of the css style coding, just in case.

Expand|Select|Wrap|Line Numbers
  1. <style>
  2. body {
  3. margin: 0px 60px 0px 60px;
  4. color: #000000;
  5. font-size: 11 px;
  6. font-family: arial ;
  7. line-height:12px;
  8. text-align:justify
  9. }
  10.  
  11. td {
  12. font-size: 11px;
  13. font-family: arial ;
  14. line-height:12px;
  15. color:#000000;
  16. font-size:11px;
  17. text-align:justify;}
  18. </style>
Expand|Select|Wrap|Line Numbers
  1. <div align=center>
  2. <TABLE WIDTH=845 BORDER=0 CELLPADDING=0 CELLSPACING=0>
  3. <TR>
  4. <TD style="position:relative" COLSPAN=17 background="images/st.jpg" WIDTH=845 HEIGHT=224 valign=top>
  5. <div align=right><br>Join the Mailing List</font><br>
  6. <input size="17" name="" type="text" value="">
  7. <input
  8. type="submit" name="hop 11"
  9. value="Submit"></div>
  10. <br><bR></div>
  11.  
  12. </TD>
  13. <TD>
  14. <IMG SRC="images/spacer.gif" WIDTH=1 HEIGHT=224 ALT=""></TD>
  15. </TR>
  16. <TR>
  17. <TD style="position:relative" COLSPAN=2 ROWSPAN=6 background="images/_02.jpg" WIDTH=191>
  18. <div style="position:absolute;width:100px;left:60px;top:-20px;z-index:1">
  19. <img src="images/r.jpg"><br><br>
  20. <img src="images/e.jpg"><bR><br>
  21. <img src="images/e.jpg"><br><br>
  22. <img src="images/n.jpg" height=90 width=76>
  23. <TD COLSPAN=6>
  24. <IMG SRC="images/_03.jpg" WIDTH=201 HEIGHT=18 ALT=""></TD>
  25. <TD ROWSPAN=3>
  26. <a href="sez/prop.htm" target=iframe><IMG SRC="images/_04.jpg" WIDTH=53 HEIGHT=51 ALT="" border=0></A></TD>
  27. <TD COLSPAN=6 ROWSPAN=2>
  28. <IMG SRC="images/_03-06.jpg" WIDTH=218 HEIGHT=21 ALT=""></TD>
  29. <TD COLSPAN=2 ROWSPAN=6 background="images/_06.jpg" WIDTH=182 HEIGHT=324></TD>
  30. <TD>
  31. <IMG SRC="images/spacer.gif" WIDTH=1 HEIGHT=18 ALT=""></TD>
  32. </TR>
  33. <TR>
  34.  
  35. <td COLSPAN=1 ROWSPAN=2 background="images/bio_jpg">
  36. <div id="bio"><a href=sez/bio.htm target=iframe></A><DIV></td>
  37. <TD COLSPAN=2 ROWSPAN=2>
  38. <div id="tour"><a href=sez/_tour.htm target=iframe></A><DIV></TD>
  39. <TD COLSPAN=3 ROWSPAN=2>
  40. <div id="merc"><a href=sez/m.htm target=iframe></A><DIV></TD>
  41. <TD>
  42. <IMG SRC="images/spacer.gif" WIDTH=1 HEIGHT=3 ALT=""></TD>
  43. </TR>
  44. <TR>
  45. <TD COLSPAN=3>
  46. <div id="live"><a href=sez/ix.htm target=iframe></A><DIV></TD>
  47. <TD COLSPAN=2>
  48. <div id="christ"><a href=family.htm target=iframe></A><DIV></TD>
  49. <TD ROWSPAN=2>
  50. <div id="art"><a href=t.htm target=iframe></A><DIV></TD>
  51. <TD>
  52. <IMG SRC="images/spacer.gif" WIDTH=1 HEIGHT=30 ALT=""></TD>
  53. </TR>
  54. <TR>
  55. <TD COLSPAN=2 ROWSPAN=2>
  56. <IMG SRC="images/_13.jpg" WIDTH=74 HEIGHT=31 ALT=""></TD>
  57. <TD COLSPAN=2 ROWSPAN=2>
  58. <div id="links"><a href=sez/_links.htm target=iframe></A><DIV></TD>
  59. <TD ROWSPAN=2>
  60. <div id="contact"><a href=sez/contact.htm target=iframe></A><DIV></TD>
  61. <TD COLSPAN=3 ROWSPAN=2>
  62. <div id="guestbook"><a href="http://108574.netguestbook.com/
  63. <!--http://www.ultraguest.com/view/1155828420-->" target=iframe></A><DIV></TD>
  64. <TD COLSPAN=3 ROWSPAN=2>
  65. <div id="s"><a href=sez/st.htm target=iframe></A><DIV></TD>
  66. <TD ROWSPAN=2>
  67. <IMG SRC="images/_03-19.jpg" WIDTH=43 HEIGHT=31 ALT=""></TD>
  68. <TD>
  69. <IMG SRC="images/spacer.gif" WIDTH=1 HEIGHT=1 ALT=""></TD>
  70. </TR>
  71. <TR>
  72. <TD>
  73. <IMG SRC="images/_03-20.jpg" WIDTH=51 HEIGHT=30 ALT=""></TD>
  74. <TD>
  75. <IMG SRC="images/spacer.gif" WIDTH=1 HEIGHT=30 ALT=""></TD>
  76. </TR>
  77. <TR>
  78. <TD COLSPAN=13><IFRAME HEIGHT="242" WIDTH="472" SRC="sez/.htm" NAME="iframe" NORESIZE FRAMEBORDER="0" MARGINHEIGHT="0" MARGINWIDTH="0"></IFRAME>
  79. <!---IMG SRC="images/rt_20.jpg" WIDTH=472 HEIGHT=242 ALT=""---></TD>
  80. <TD>
  81. <IMG SRC="images/spacer.gif" WIDTH=1 HEIGHT=242 ALT=""></TD>
  82. </TR>
  83. <TR>
  84. <TD>
  85. <IMG SRC="images/_21.jpg" WIDTH=146 HEIGHT=62 ALT=""></TD>
  86. <TD COLSPAN=5 ROWSPAN=2>
  87. <IMG SRC="images/_22.jpg" WIDTH=173 HEIGHT=63 ALT=""></TD>
  88. <TD COLSPAN=5 ROWSPAN=2>
  89. <a href="man.htm" target=_blank><IMG SRC="images/_.jpg" WIDTH=184 HEIGHT=63 ALT="" border=0></A></TD>
  90. <TD COLSPAN=5 ROWSPAN=2 background="images/_24.jpg" WIDTH=194 HEIGHT=63>
  91. </TD>
  92. <TD background="images/_21-26.jpg" WIDTH=148 HEIGHT=62>
  93. </TD>
  94. <TD>
  95. <IMG SRC="images/spacer.gif" WIDTH=1 HEIGHT=62 ALT=""></TD>
  96. </TR>
  97. <TR>
  98. <TD>
  99. <IMG SRC="images/26.jpg" WIDTH=146 HEIGHT=1 ALT=""></TD>
  100. <TD>
  101. <IMG SRC="images/27.jpg" WIDTH=148 HEIGHT=1 ALT=""></TD>
  102. <TD>
  103. <IMG SRC="images/spacer.gif" WIDTH=1 HEIGHT=1 ALT=""></TD>
  104. </TR>
  105. <TR>
  106. <TD>
  107. <IMG SRC="images/spacer.gif" WIDTH=146 HEIGHT=1 ALT=""></TD>
  108. <TD>
  109. <IMG SRC="images/spacer.gif" WIDTH=45 HEIGHT=1 ALT=""></TD>
  110. <TD>
  111. <IMG SRC="images/spacer.gif" WIDTH=57 HEIGHT=1 ALT=""></TD>
  112. <TD>
  113. <IMG SRC="images/spacer.gif" WIDTH=17 HEIGHT=1 ALT=""></TD>
  114. <TD>
  115. <IMG SRC="images/spacer.gif" WIDTH=33 HEIGHT=1 ALT=""></TD>
  116. <TD>
  117. <IMG SRC="images/spacer.gif" WIDTH=21 HEIGHT=1 ALT=""></TD>
  118. <TD>
  119. <IMG SRC="images/spacer.gif" WIDTH=65 HEIGHT=1 ALT=""></TD>
  120. <TD>
  121. <IMG SRC="images/spacer.gif" WIDTH=8 HEIGHT=1 ALT=""></TD>
  122. <TD>
  123. <IMG SRC="images/spacer.gif" WIDTH=53 HEIGHT=1 ALT=""></TD>
  124. <TD>
  125. <IMG SRC="images/spacer.gif" WIDTH=13 HEIGHT=1 ALT=""></TD>
  126. <TD>
  127. <IMG SRC="images/spacer.gif" WIDTH=45 HEIGHT=1 ALT=""></TD>
  128. <TD>
  129. <IMG SRC="images/spacer.gif" WIDTH=10 HEIGHT=1 ALT=""></TD>
  130. <TD>
  131. <IMG SRC="images/spacer.gif" WIDTH=56 HEIGHT=1 ALT=""></TD>
  132. <TD>
  133. <IMG SRC="images/spacer.gif" WIDTH=43 HEIGHT=1 ALT=""></TD>
  134. <TD>
  135. <IMG SRC="images/spacer.gif" WIDTH=51 HEIGHT=1 ALT=""></TD>
  136. <TD>
  137. <IMG SRC="images/spacer.gif" WIDTH=34 HEIGHT=1 ALT=""></TD>
  138. <TD>
  139. <IMG SRC="images/spacer.gif" WIDTH=148 HEIGHT=1 ALT=""></TD>
  140. <TD></TD>
  141. </TR>
  142. </TABLE>
Sep 6 '06 #1
19 60359
limweizhong
62 New Member
hello , I have an issue positionating some pics I want to anchor to an existing table cell but I cant just place regular position on the cell because the background is fixed height and the set of pics is bigger then fixed space. SO I put them in a position:absolu te div and I gave a position:relati ve to the container td.
This seems to work in IE but in Firefox position is relative to the browser window, not the cell. I need a compatible solution to anchor this vertical set of pics relatively to a specific area of the layout not the general browser window sigh...
...
I too have the same bug. I tried on a simpler code and it worked in IE but not in firefox.
Expand|Select|Wrap|Line Numbers
  1. <html>
  2. <body>
  3. asdf<br>
  4. asdf<br>
  5. asdf<br>
  6. asdf<br>
  7. <table cellpadding='0' cellspacing='0'><tr><td style='position:relative;'>asdf<div style='position:absolute;left:0%;top:0%;'>qwer</div></td></tr></table>
  8. </body>
  9. </html>
According to http://www.w3.org/TR/2006/WD-CSS21-2...-block-details
,
4. If the element has 'position: absolute', the containing block is established by the nearest ancestor with a 'position' of 'absolute', 'relative' or 'fixed'...
Dec 6 '06 #2
drhowarddrfine
7,435 Recognized Expert Expert
I am extremely busy right now so I apologize for not being able to look at the code in depth. The problem is probably IE. IE expands containers to contain floated and absolutely positioned elements. This is incorrect behavior. But to get modern browsers to do what you want, try adding overflow:auto; to the containing element and see if that fixes it.

I'll try and look into this again later.
Dec 6 '06 #3
Splat
5 New Member
I am extremely busy right now so I apologize for not being able to look at the code in depth. The problem is probably IE. IE expands containers to contain floated and absolutely positioned elements. This is incorrect behavior. But to get modern browsers to do what you want, try adding overflow:auto; to the containing element and see if that fixes it.

I'll try and look into this again later.
I have similar code which Safari & IE have no trouble with - it seems to be FireFox out of line. In mine, a table with relative position contains a table with absolute postion; if you apply "top: 0px" to the latter, FireFox takes this - wrongly - to mean the top of the browser window, not the top of the containing element.
Jan 5 '07 #4
drhowarddrfine
7,435 Recognized Expert Expert
Firefox does not take it wrong but the definition from the W3C is this:

The effect of 'position:relat ive' on table-row-group, table-header-group, table-footer-group, table-row, table-column-group, table-column, table-cell, and table-caption elements is undefined.

I think this may be because tables are not to be used for layout and positioning is a layout attribute.
Jan 6 '07 #5
mosteo
1 New Member
I have similar code which Safari & IE have no trouble with - it seems to be FireFox out of line. In mine, a table with relative position contains a table with absolute postion; if you apply "top: 0px" to the latter, FireFox takes this - wrongly - to mean the top of the browser window, not the top of the containing element.
I have also hit this bug with firefox 2.0. An absolute div within a relative div gets the correct left but top is from the top of page? Do you know of any workaround?
Jan 11 '07 #6
drhowarddrfine
7,435 Recognized Expert Expert
Again, this is NOT a bug. This is correct behavior. If any other browser (that is, IE) does it differently, it is due to a bug in IE. Firefox is performing correctly.

Absolutely positioned elements are removed from the document flow. They position themselves relative to their parent. If a containing div is positioned relative, then the contained absolutely positioned div will position itself within that parent. HOWEVER, because the absolutely positioned element is removed from the flow, the parent div will collapse because, as far as it is concerned, it does not contain anything.

If the containing div is not positioned, then the absolutely positioned div will use the next level up parent which could be the body, in your case.
Jan 11 '07 #7
Splat
5 New Member
Again, this is NOT a bug. This is correct behavior. If any other browser (that is, IE) does it differently, it is due to a bug in IE. Firefox is performing correctly.

Absolutely positioned elements are removed from the document flow. They position themselves relative to their parent. If a containing div is positioned relative, then the contained absolutely positioned div will position itself within that parent. HOWEVER, because the absolutely positioned element is removed from the flow, the parent div will collapse because, as far as it is concerned, it does not contain anything.

If the containing div is not positioned, then the absolutely positioned div will use the next level up parent which could be the body, in your case.
Many thanks. Firefox may be strictly correct, but what is needed is a workaround that all browsers will accept.

The brief from my client is to position the 'Content' table (their term) in the centre of the browser window, which I have done by making a 100% w/h table with one cell set to align centre/middle. Therefore the position of the 'Content' table is undetermined by CSS.

'Content' table is set to position relative. It contains a 'Blurb' table set to position absolute.

This works (as it happens) in all browsers apart from FF, & (of course) as long as I don't try to position 'Blurb' relative to 'Content', all is well in FF too.

But what if I needed to position it (e.g.) 150 pixels from top? I did in fact try this using divs instead of tables, but this wouldn't work in IE. Since my client insists on tables I may need to have a viable method at some time in the future, & as others seem to have similar problems it might be of more than academic interest to find a fix.
Jan 12 '07 #8
Splat
5 New Member
Many thanks. Firefox may be strictly correct, but what is needed is a workaround that all browsers will accept.

The brief from my client is to position the 'Content' table (their term) in the centre of the browser window, which I have done by making a 100% w/h table with one cell set to align centre/middle. Therefore the position of the 'Content' table is undetermined by CSS.

'Content' table is set to position relative. It contains a 'Blurb' table set to position absolute.

This works (as it happens) in all browsers apart from FF, & (of course) as long as I don't try to position 'Blurb' relative to 'Content', all is well in FF too.

But what if I needed to position it (e.g.) 150 pixels from top? I did in fact try this using divs instead of tables, but this wouldn't work in IE. Since my client insists on tables I may need to have a viable method at some time in the future, & as others seem to have similar problems it might be of more than academic interest to find a fix.
Quick clarification: a surrounding table contains the 'Content' table (position relative) which contains the 'Blurb' table (position absolute). The question is how to position 'Blurb' in relation to 'Content', since "top=howeve r many pixels" is not dependable.
Jan 12 '07 #9
drhowarddrfine
7,435 Recognized Expert Expert
Well, there is IE and there is everyone else. It is always better to code to standards compliance than to IE because you can always adjust for IE but you can't adjust invalid code for everyone else. The problem you mention is not just Firefox but all modern browsers.

I don't recall if the table issue is still true in IE7 which brings up another point. IE7 has made a half-hearted attempt to be more standards compliant so it now performs closer to Firefox and other modern browsers but less like IE6. So now there are further 'hacks' that must be made to bring IE6 and IE7 into line.

I can't give more examples and help right now because I reformatted my computer to swap with my wife and I don't have my dev tools or other browsers available to test in. Hope to have it all back by tonight.

This is why we should never use tables for layout. You said you couldn't get divs to work in IE but there are known ways to hack IE.
Jan 12 '07 #10

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

Similar topics

0
2844
by: Mike | last post by:
I've been working on a pop-up menu, one of those where you mouse over a button and a submenu pops up. Because the client wanted the menu centered, I gave the starting point of the submenu an absolute position, then used relative position to place the menu where I want it beneath the buttons. The code for the menu is posted below (in Javascript). Although I can't get this to happen on my computer (using IE5.0, 5.5, and Netscape 7.0), the...
3
8504
by: Alexander Fischer | last post by:
Hello everybody, can someone help me with this problem: I'm creating a page with a sidebar, and I wanted to create the sidebar as a div which gets a "position:absolute". The problem: if the sidebar's content is longer than the main content, my IE6 will not create a vertical scrollbar for the page, which makes the lower part of the sidebar unreadable. Take this code: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"...
6
4861
by: Harald Kirsch | last post by:
In the W3C document about CSS2, I read at http://www.w3.org/TR/REC-CSS2/visuren.html#choose-position the following: absolute The box's position (and possibly size) is specified with the 'left', 'right', 'top', and 'bottom' properties. These properties
4
3136
by: Peter Pfannenschmid | last post by:
Hello experts, I would be very grateful if you would have a look at the following URL: http://www.omeganet.de/test.html The html file and the associated style have been validated successfully by the online validators of w3.org.
6
18828
by: Gert Brinkmann | last post by:
Hello, as I understand the specs http://www.w3.org/TR/CSS21/visuren.html#x19 an absolute positioned block element is positioned relative to its parent element. This is told in the german selfhtml reference, too: http://de.selfhtml.org/navigation/css.htm#positionierung In fact firefox and konqueror do position the block relativ to the window border. This is explained here, too: http://www.w3schools.com/dhtml/dhtml_css.asp
6
7575
by: alex | last post by:
I'm playing around with css popups a la http://www.meyerweb.com/eric/css/edge/popups/demo.html for here: http://www.redbrick.dcu.ie/~alex/golf/courseinfo.html (css) http://www.redbrick.dcu.ie/~alex/golf/css/golf-main.css
6
6478
by: axlq | last post by:
I've spent most of the day struggling with what I thought would be a trivial problem. I have a hidden element that appears, outside of the normal flow, when the mouse hovers over an inline element. HOWEVER, I want the hidden element positioned at a location of my choosing relative to that inline element. Is this possible?
6
2874
by: ThunderMusic | last post by:
Hi, I think the subject says it all... thanks ThunderMusic
1
2176
oranoos3000
by: oranoos3000 | last post by:
hi would you please compare while position is relative and relate that with it's ancestor position and the other sibling position , and too for while position is absolute and relate that with position it's acestor and position it's sibling? thanks alot for your help.
0
8305
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8825
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8732
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
7324
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6163
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5632
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4302
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2726
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1953
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.