Flawed
Well based on your description and code examples I was under the impression that you needed to place text "on top" of an image. By placing the image as a fixed bg in the div you can do that.
I gave the first snip 5 minutes and experienced the same trouble you had, that's why I placed the image as a bg instead of "normally" in BoxA.
How about this one then:
code:
<!doctype html public "-//W3C//DTD HTML 4.0 //EN">
<html>
<head>
<title>Yo!</title>
<script language="JavaScript" type="text/javascript">
function setPos(objF,objB){
obFront = document.getElementById(objF);
obBack = document.getElementById(objB);
h2 = obBack.offsetHeight;
newTop = "-"+h2;
obFront.style.top = newTop;
}
</script>
</head>
<body onload="setPos('boxInFront','boxBehind')">
<h1>Text over image</h1>
<div id="container" style="position: relative; top:10px; left:10px; border:1px solid #000000; padding:10px; width:400px; overflow:visible;">
<div id="boxBehind" style="position:relative;top 10;left:10; width:380; height:100; overflow;visible;">
<img src="DmSsneakPreviewSmall.gif"><br>
Text here to appear in image div...<br>
Text here to appear in image div...<br>
Text here to appear in image div...<br>
Text here to appear in image div...<br>
Text here to appear in image div...<br>
Text here to appear in image div...<br>
Text here to appear in image div...<br>
Text here to appear in image div...<br>
Text here to appear in image div...<br>
Text here to appear in image div...<br>
Text here to appear in image div...<br>
Text here to appear in image div...<br>
Text here to appear in image div...<br>
Text here to appear in image div...<br>
Text here to appear in image div...<br>
Text here to appear in image div...<br>
Text here to appear in image div...<br>
Text here to appear in image div...<br>
Text here to appear in image div...<br>
Text here to appear in image div...<br>
Text here to appear in image div...<br>
Text here to appear in image div...<br>
Text here to appear in image div...<br>
Text here to appear in image div...<br>
Text here to appear in image div...<br>
Text here to appear in image div...<br>
Text here to appear in image div...<br>
Text here to appear in image div...<br>
</div>
<div id="boxInFront" style="position:relative; top:-80px;left:0px; border:1px solid #CDCDCD;">
Text here to appear above image...<br>
Text here to appear above image...<br>
Text here to appear above image...<br>
Text here to appear above image...<br>
Text here to appear above image...<br>
Text here to appear above image...<br>
</div>
</div>
</body>
</html>
More like it?
Both divs (boxInFront and boxBehind) can now expand the height of the "container" div.
The problem here is that you need to adjust the "top:-XXpx" in "boxInFront" accordingly to the height of the div "boxBehind" you want to place the text on top of.
To handle this I hacked a quick & dirty onload function that does the adjustment, at least roughly.
Unfortunatley this seems to be IE only, I can't remember how to get the same data in NS/Moz and I don't have the time right now to search for it.
All of this stems from the fact that position:absolute lifts the object out of the hierachy of the source code, that's why the surrounding container can't adjust the height to the content, the content isn't there...
position:relative keeps the object in the source codes hierarchy and places it in relation to the object before it in the code.
Use it or lose it your choice.
/Dan
{cell 260}
-{ a vibration is a movement that doesn't know which way to go }-