View Full Version : having trouble centering layers
natashapowell
04-14-2001, 06:38 PM
I need to center a layer that is Netscape visible in all it's glories ( up to and including NS6) but with compatability with all IE's..
Found a few sites with code, but finding it difficult to make work. Basically I need the code exactly how it should be with a clear instruction as to where i should put the rest of the page's content.
Please please please
kevin
04-14-2001, 07:27 PM
Put the entire layer in a table and center the table...
Or put the entire layer inside of a DIV and center the DIV.
Try both and see which works best with your code.
<div align=center>
the rest of the layer here
</div>
<table border=0 cellspacing=0 cellpadding=0 align=center><tr><td>
the rest of the layer here
</td></tr></table>
Kevin
natashapowell
04-16-2001, 05:09 AM
Thanks for your reply - however, it is slightly different - not a layer I think
go to Brainjar.com and look at his menu bar . the menu bar is copied from there - with his permission, but I cannot make it appear like his. i don't want to use frames.
kevin
04-16-2001, 07:51 PM
Well, I don't know what you see on brainjar.com but I see a terrible menu/navbar. The text is all run together, then you must first click on it to see the drop down boxes, then they will not close unless you click on a link...and the drop down box covers the menu, it's a mess, at least in IE5 it's a mess.
Anyway, that page is linked to a style sheet that is most likely controlling most or all the content, here is the link to the style sheet, see if you can figure it out...
http://www.brainjar.com/common/main.css
Kevin
COBOLdinosaur
04-21-2001, 04:48 PM
Two things if you ar going to use a DIV for a layer in Nescrap 4, you have to add
style="position:absolute" or you will not be abel to reference as a layer for repositioning.
Second the style sheet is IE only, probably IE5 only. No chance you are going to use that to do anything in Netscrap.
Cornelius7
04-28-2001, 03:32 PM
I hope you saw brainjar's pop-up message when trying to access the site with Netscape4 ...: he's given up on Netscape4 and I the visitor is lucky if there's anything visible on the page. Well, worse than that, Netscape actually crashes as soon as as the page starts loading. I would stay away from that menu bar.
I have a very simple version of a menu bar with absolute positioning. If you are intersted and don't need 'centered' positioning (still haven't gotten that to work with Netscape), I can e-mail it to you. It works with Netscape4+ and IE4+.
Good luck.
Unregistered
05-18-2001, 02:42 AM
function centerIt(elem_id) {
if (document.all) {
if (document.readyState == 'complete') {
el = document.all[elem_id];
el.style.pixelLeft = Math.round((document.body.clientWidth/2)-(el.offsetWidth/2));
el.style.pixelTop = Math.round((document.body.clientHeight/2)-(el.offsetHeight/2));
}
} else if (document.getElementById) {
el = document.getElementById(elem_id);
el.style.left = (Math.round((window.innerWidth/2)-(el.offsetWidth/2)))+'px';
el.style.top = (Math.round((window.innerHeight/2)-(el.offsetHeight/2)))+'px';
} else if (document.layers) {
el = document[elem_id];
el.moveToAbsolute(Math.round((window.innerWidth/2)-(el.clip.width/2)),Math.round((window.innerHeight/2)-(el.clip.height/2)));
}
}
This will center (in the window's 'live area') any unnested, positioned element. Didn't test NS6, so, good luck! I'm not sure this is what you were looking for, but....
Dr. Web
05-18-2001, 03:19 AM
speaking of cool menus....
www.bratta.com
the author lists the browser support next to the download. Just hit the scriptorioum.
vBulletin® v3.6.7, Copyright ©2000-2009, Jelsoft Enterprises Ltd.