Forum Moderators: not2easy

Message Too Old, No Replies

Abs positioning causing later element to appear first!

A beginner's challenge

         

kriskd

9:12 pm on Dec 12, 2004 (gmt 0)

10+ Year Member



I have a table that I have absolutely positioned 126px from the top. After that, I have a block of text that has no positioning associated with it. What I expect is my table to appear as positioned and directly following that, my block of text.

However, what happens in IE 6.0 is the block of text appears at the top of the browser above my absolutely positioned table when in the code it comes after the table!

Because the table could vary in height depending on what is in it, I can't absolutely position the block of text.

What am I doing wrong or missing? Here is my code:


<html>

<head>
<STYLE type="text/css">

body {margin: 0;
background: #E9E0AA;}

td{width: 50%}

.maintable { position: absolute;
top: 126px;
left: -2px;
border-style: solid;
width: 100%}

.test {color: white;
font-size: 14;
background-color: #826AA9;
font-family: arial}

</style>
</head>

<table class="maintable">
<tr>
<td>Test test</td>
<td>Test test</td>
</tr>
<tr>
<td>Test test</td>
<td>Test test</td>
</tr>
</table>
<p class="test">Test Test</P>

</html>

BonRouge

9:49 pm on Dec 12, 2004 (gmt 0)

10+ Year Member



Well, 'position:absolute' takes the element out of the flow of the document, so the text naturally positions itself at the top. If you really need to use 'position:absolute' instead of just 'margin-top:...' or something like that, you could put the table and text inside an a div and use the positioning on that instead of the table. In that way, the whole thing will be taken out of the natural flow of the document but everything within the div shoul be positioned relative to each other.

kriskd

10:38 pm on Dec 12, 2004 (gmt 0)

10+ Year Member



BonRouge --

Thanks for your quick reply. Since I haven't been practicing my CSS like a good girl, the option of using margin-top eluded me.

Aren't easy questions the best? :)