Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Javascript > center div over another div

Reply
Thread Tools

center div over another div

 
 
Gernot Frisch
Guest
Posts: n/a
 
      03-16-2006



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>


 
Reply With Quote
 
 
 
 
Randy Webb
Guest
Posts: n/a
 
      03-16-2006
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/
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
<div ... /> and <div ...></div> K Viltersten ASP .Net 4 03-31-2009 07:33 PM
VOIP over VPN over TCP over WAP over 3G Theo Markettos UK VOIP 2 02-14-2008 03:27 PM
Naming of core NASA center with the words "Mission Control Center" & mass use of religious anthem sounding word "Mission" in Context of Space Exploration & the Moon Landing Hoax moonlandinghoaxreligious@yahoo.com Digital Photography 0 09-27-2005 08:28 PM
NS/FF don't change div offsetWidth when div innerHTML is added toand div becomes wider mscir Javascript 3 06-26-2005 04:04 PM
Q: Div A inside Div B is larger than Div B Dwayne Madsen Javascript 1 06-01-2005 03:02 PM



Advertisments