PDA

View Full Version : Top Navigational Bar II - Centering Help



sirjakeyjake
02-09-2005, 06:23 PM
Top Navigational Bar II
http://www.dynamicdrive.com/dynamicindex1/topnavbar.htm

Since I didn't start the other post, and it looks to be drying up, I'll start over.

I can't seem to center the headings inside the nav boxes. The in-script comments say to uncomment in this one place to center the bar. The help on the DD page says that should center the bar as well as the individual headers. No matter what I try, the headers themselves will not center, though the bar itself is centered.

BTW, I'm using "navcond.js" vs. "dhtmllib.js" and "navbar.js", in case that makes a difference.

Any help would be appreciated...thanks!

=jb=

speedracer
02-10-2005, 09:37 AM
hmm...this is an old script.

try this to center the menu on a page, change your init() function to:


function init() {

// Get width of window, need to account for scrollbar width in Netscape.

fullWidth = getWindowWidth()
- (isMinNS4 && getWindowHeight() < getPageHeight() ? 16 : 0);

myNavBar1.resize(770);
myNavBar1.create();
myNavBar1.setzIndex(2);
//UNCOMMENT BELOW LINE TO MOVE MENU DOWN

// myNavBar1.resize(fullWidth); may be able to substitute a number like 500 for fullWidth ... without this line, the bar does not stretch across the entire screen...it uses the minimum needed as called from the size of the main menu choices
var menuWidth = myNavBar1.getWidth();
if(document.all){
var x = document.body.scrollLeft+document.body.clientWidth/2-menuWidth/2
}
else
if(document.layers){
var x = pageXOffset+window.innerWidth/2-menuWidth/2
}

myNavBar1.moveTo(x,125);
}




to center the menu item:
dhtmlMenu.addItem(new NavBarMenuItem("<center>News</center>", ""));

sirjakeyjake
02-10-2005, 10:04 PM
to center the menu item:
dhtmlMenu.addItem(new NavBarMenuItem("<center>News</center>", ""));

PERFECT!!! This is exactly what I needed. And so stupidly-simple...

Thank you!

=jb=