Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    New to the CF scene
    Join Date
    Feb 2011
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Nav Bar Central Allignment Issue

    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.

    Code:
    <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-->
    Code:
    #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}

  • #2
    Master Coder Excavator's Avatar
    Join Date
    Dec 2006
    Location
    Alaska
    Posts
    9,738
    Thanks
    22
    Thanked 1,836 Times in 1,820 Posts
    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.
    Validate often DURING development - Use it like a splelchecker | Debug during Development |Write it for FireFox, ignore IE
    Use the right DocType | Validate your markup | Validate your CSS | Why validating is good | Why tables are bad

  • #3
    New to the CF scene
    Join Date
    Feb 2011
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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

  • #4
    Master Coder Excavator's Avatar
    Join Date
    Dec 2006
    Location
    Alaska
    Posts
    9,738
    Thanks
    22
    Thanked 1,836 Times in 1,820 Posts
    Quote Originally Posted by jpw1984 View Post
    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.
    Validate often DURING development - Use it like a splelchecker | Debug during Development |Write it for FireFox, ignore IE
    Use the right DocType | Validate your markup | Validate your CSS | Why validating is good | Why tables are bad


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •