Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   Javascript (http://www.velocityreviews.com/forums/f68-javascript.html)
-   -   center div over another div (http://www.velocityreviews.com/forums/t923610-center-div-over-another-div.html)

Gernot Frisch 03-16-2006 01:10 PM

center div over another div
 



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;&nbs p;&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+'\').st yle.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>



Randy Webb 03-16-2006 01:42 PM

Re: center div over another div
 
Gernot Frisch said the following on 3/16/2006 8:10 AM:
> I want to center the div "KungFu" over the div "header".
> Does not.


news:comp.infosystems.www.authoring.stylesheets is a better place to ask
CSS questions.

--
Randy
comp.lang.javascript FAQ - http://jibbering.com/faq & newsgroup weekly
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/


All times are GMT. The time now is 04:53 AM.

Powered by vBulletin®. Copyright ©2000 - 2013, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.


1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57