Advertisement
Help Keep Boards Alive. Support us by going ad free today. See here: https://subscriptions.boards.ie/.
If we do not hit our goal we will be forced to close the site.

Current status: https://keepboardsalive.com/

Annual subs are best for most impact. If you are still undecided on going Ad Free - you can also donate using the Paypal Donate option. All contribution helps. Thank you.
https://www.boards.ie/group/1878-subscribers-forum

Private Group for paid up members of Boards.ie. Join the club.

Center align nav buttons in css

  • 22-10-2012 04:24PM
    #1
    Registered Users, Registered Users 2 Posts: 128 ✭✭


    Sorry if this is a silly question, but I am trying to center align Horizontal nav buttons on a website. And how do I set the same width for every button? I'm worse than totally new to this but have a project to do, so any help would be great thanks.

    Al.

    Attached both the Home page and the css code in text doc's.


Comments

  • Registered Users, Registered Users 2 Posts: 2 mccarthyi


    To centre the links add text-align:center; to the ul#nav li a rule, to set a width for all the links add width:?px (where ? is the width you want) to the same rule;


  • Registered Users, Registered Users 2 Posts: 128 ✭✭alanc


    Thanks for your speedy reply, but I cant seem to get that working. It looks like it is just tabbed in. Sorry I'll say again I am totally new to this.

    AL.


  • Registered Users, Registered Users 2 Posts: 2 mccarthyi


    Attached are two screenshots. Capture1 shows your page with the code you attached. Capture2 show how it looks with the changes I suggested.
    The css should look like this
    ul#nav li a {
       float: left;
       padding: 8px 5px 3px 5px;
       line-height: 2em;
       margin-right: 5px;
       background-color: #034a7f;
       color: #fff;
       font-weight: bold;
       text-decoration: none;  
       [B]text-align:center; 
       width:140px;[/B]}
    


  • Registered Users, Registered Users 2 Posts: 128 ✭✭alanc


    Thanks mccarthyi,

    Not sure what I was doing wrong, works perfectly, cheers.

    AL.


Advertisement