center div over another div

G

Gernot Frisch

I want to center the div "KungFu" over the div "header".
Does not.


<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//DE">
<html>
<body>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>

<br>
<nobr>
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<div id="header">HERE IST THE HEADER</div></p>
</nobr>

<div id="KungFu"></div>
<script type="text/javascript">
//
//
//
function displayFloatingDiv(divId, title, message, center_over_Id,
width, height)
{

var left, top;
var parent = document.getElementById(center_over_Id);
left = Math.max(0, parent.offsetLeft+ (parent.offsetWidth-width));
top = Math.max(0, parent.offsetTop+ (parent.offsetHeight-height));

var Div = document.getElementById(divId);
Div.style.position = 'absolute';
Div.style.width = width + 'px';
Div.style.height = height + 'px';
Div.style.left = left + 'px';
Div.style.top = top + 'px';

alert(parent+' - l:'+left+' t:'+top+'
w:'+(parent.offsetWidth-width));

var addHeader;

addHeader = '<table style="width:' + width + 'px" bgcolor="red">'
+
'<tr><td
onclick="document.getElementById(\''+divId+'\').style.visibility=\'hidden\'">'
+ title + '</td>' +
'<td style="width:18px" align="right">' +
'Close...</td></tr><tr><td
colspan="2">'+message+'</td></tr></table>';


// add to your div an header
Div.innerHTML = addHeader;

Div.className = 'dimming';
Div.style.visibility = "visible";
}

displayFloatingDiv("KungFu", "Title", "Some long message", "header",
320, 240);


</script>


</body></html>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,734
Messages
2,569,441
Members
44,832
Latest member
GlennSmall

Latest Threads

Top