Results 1 to 4 of 4

Thread: How to center my Nav Bar

  1. #1
    Join Date
    Dec 2007
    Posts
    31
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default How to center my Nav Bar

    This is the html part of my code and it may be the problem.

    Code:
    <div id="navblock">
    			<ul id="mainNav">
    				<li><a href="../../index.php" title="Tarantula Database Home">Home</a></li>
    				<li><a href="../pages/search.php" title="Tarantula Database Search">Search</a></li>
    				<li><a href="../pages/submit.php" title="Tarantula Database Submit">Submit</a></li>
    				<li><a href="index.php" title="Tarantula Database Forum">Forum</a></li>
    				<li><a href="../pages/contact.php" title="Tarantula Database Contact">Contact</a></li>
    			</ul>
    		</div>

    With the css code it was floating to the left and looked fine but it wan't centered. it look like like this

    http://www.tarantuladatabase.com/this1.JPG

    So I changed my css code to this

    Code:
      }
    
     ul#mainNav li{
    	border-top: 1px solid #766454;
    	border-bottom: 1px solid #766454;
    	margin-right: auto;
    	margin-left: auto;
      }
    And that didnt work either

    http://www.tarantuladatabase.com/assets/forum

    Any idea how I can center it?

  2. #2
    Join Date
    Jul 2007
    Location
    Azerbaijan, Baku
    Posts
    144
    Thanks
    11
    Thanked 27 Times in 25 Posts

    Default

    Can u insert here what css was here before?

  3. #3
    Join Date
    Sep 2006
    Location
    St. George, UT
    Posts
    2,769
    Thanks
    3
    Thanked 157 Times in 155 Posts

    Default

    Try:

    Code:
    #navblock {
     margin: 0 auto;
    }
    Hope this helps.
    "Computer games don't affect kids; I mean if Pac-Man affected us as kids, we'd all be running around in darkened rooms, munching magic pills and listening to repetitive electronic music." - Kristian Wilson, Nintendo, Inc, 1989
    TheUnlimitedHost | The Testing Site | Southern Utah Web Hosting and Design

  4. #4
    Join Date
    Jul 2006
    Location
    just north of Boston, MA
    Posts
    1,806
    Thanks
    13
    Thanked 72 Times in 72 Posts

    Default

    Quote Originally Posted by thetestingsite View Post
    Try:

    Code:
    #navblock {
     margin: 0 auto;
    }
    Hope this helps.
    you need to either include a width: property or a text-align:center; in order for the above code to work properly across all browsers.

    Code:
    #navblock {
        margin: 0 auto;
        width: 80%;
    }

Bookmarks

Posting Permissions

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