Velocity Reviews - Computer Hardware Reviews

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

Thread Tools

center div over another div

Gernot Frisch
Posts: n/a

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

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//DE">

<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>

<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); = 'absolute'; = width + 'px'; = height + 'px'; = left + 'px'; = top + 'px';

alert(parent+' - l:'+left+' t:'+top+'

var addHeader;

addHeader = '<table style="width:' + width + 'px" bgcolor="red">'
onclick="document.getElementById(\''+divId+'\').st yle.visibility=\'hidden\'">'
+ title + '</td>' +
'<td style="width:18px" align="right">' +

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

Div.className = 'dimming'; = "visible";

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



Reply With Quote
Randy Webb
Posts: n/a
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.

comp.lang.javascript FAQ - & newsgroup weekly
Javascript Best Practices -
Reply With Quote

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 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