...

View Full Version : Nav Bar Central Allignment Issue



jpw1984
04-12-2011, 07:47 PM
I have a nav bar that I am struggling to get positioned correctly. The UL is perfectly centered in teh navigation div, but I can't get the links to be centrally alligned without screwing up the design of it. It's a simple nav bar, but I have coded and created the links to have an onstate and hover arrow at the bottom of them.

Anyone can help that be great.


<div id="sec_nav"><!-- Begin Sec Nav-->
<ul>
<li><a href="/index" class="sec_navselect">About</a></li>
<li><a href="/portfolio" >Portfolio</a></li>
<li><a href="/prints" >Print Sales</a></li>
<li><a href="/stock" >Stock Sales</a></li>
</ul>
</div><!-- End Sec Nav-->


#sec_nav {width: 100%; background:yellow; height: 34px; background-image:url(../images/secnav_bg.jpg); background-repeat:repeat-x;}
#sec_nav ul { margin: 0 auto; list-style: none; height: 34px; width: 500px}
#sec_nav li {float: left; padding-right: 20px;}
#sec_nav a {height: 33px; color:#999999; display: block; width: auto;text-decoration: none; font-size: 10px; font-family:Verdana, Arial, Helvetica, sans-serif; width: 100%}
#sec_nav a:hover, #sec_nav a.sec_navselect {color: #333333; background-color: transparent; background-image: url("../images/secnav_arrow.jpg"); background-repeat: no-repeat;background-position: center bottom; text-decoration:none}

Excavator
04-12-2011, 08:16 PM
Hello jpw1984,
Is there any reason your ul is 500px wide? I only ask because that is much wider than the 4 li's it contains.
Narrow that ul up a bit and those links are closer to center.

You could also center that ul like this example (http://nopeople.com/CSS%20tips/menu-h_centered-ul/index.html).

jpw1984
04-12-2011, 08:29 PM
I can get it narrowed down to 281 pixels, but anything less than that means the text in the links stars to get wrapped.

However, it is still lobsided to the left.

website: www.jpwild.com

Excavator
04-12-2011, 08:42 PM
I can get it narrowed down to 281 pixels, but anything less than that means the text in the links stars to get wrapped.

However, it is still lobsided to the left.

website: www.jpwild.com

The problem with setting a width on you ul is the way things move around when the person viewing your site has different a text size than you did when you figured your width.

Look at that link I provided for a more fluid centering method that is not dependant on set widths.

Another thing, instead of padding-right on your li, padding: 0 10px; might center the text better.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum