Centering a CSS <div> Menu

Discussion in 'Web Programming' started by ~XS, Apr 3, 2009.

Centering a CSS <div> Menu
  1. Unread #1 - Apr 3, 2009 at 3:40 PM
  2. ~XS
    Joined:
    Sep 16, 2008
    Posts:
    406
    Referrals:
    0
    Sythe Gold:
    0

    ~XS Forum Addict
    Banned

    Centering a CSS <div> Menu

    Well I have a CSS menu, but it is constantly docked left, and I want to center it.

    Text alignment dosent work, as that only centers the text ON the menu, which is done already.

    I have tried adjusting left and right margins to 0, and stuff like that, but to no avail.

    HTML
    Code:
    <div id="navigation">
    <div id="menu"><ul>
    	><li><a href="#">Homepage</a></li>
    			<li><a href="#">Blogs</a></li>
    			<li><a href="#">Photos</a></li>
    			<li><a href="#">About</a></li>
    			<li class="last"><a href="#">Contact</a></li>
    		</ul></
    </div></div>
    CSS
    Code:
    /* Menu */
    
    #menu {
    	float: left;     /* No this isn't it */
    	width: 880px;
    	height: 58px;
    	
    	
    	
    }
    #navigation{
        margin:auto;
    }
    
    #menu ul {
    	margin: 0;
    	padding: 23px 0 0 20px;
    	list-style: none;
    	line-height: normal;
    }
    
    #menu li {
    	float: left;    /* Or this */
    	text-align: center;
    }
    
    #menu a {
    	display: block;
    	padding: 0 50px;
    	background: url(../../emporium1/emporium/emporium/images/img03.jpg) no-repeat right 50%;
    	text-decoration: none;
    	text-transform: uppercase;
    	font-size: 11px;
    	color: #FFFFFF;
    }
    
    #menu a:hover { 
    	color: #FFFFFF;
    }
    
    #menu .current_page_item a {
    	color: #FFFFFF;
    }
     
  3. Unread #2 - Apr 3, 2009 at 5:52 PM
  4. hampe-92
    Joined:
    Jul 10, 2008
    Posts:
    328
    Referrals:
    0
    Sythe Gold:
    0

    hampe-92 Forum Addict

    Centering a CSS <div> Menu

    easy as pie :)
    Code:
    #navigation{
      width: 880px ;
      margin-left: auto ;
      margin-right: auto ;
    }
    
     
  5. Unread #3 - Apr 4, 2009 at 2:44 AM
  6. TDD
    Joined:
    Nov 20, 2005
    Posts:
    3,191
    Referrals:
    2
    Sythe Gold:
    0

    TDD Web Design Expert
    Do Not Trade

    Centering a CSS <div> Menu

    absolutely position your #navigation:

    Code:
    #Navigation {
    position: absolute;
    margin: 0 auto;
    }
    
    that should do that.
     
< [PHP] Runescape Homeworld Signature | PHP/SQL Time Issues... >

Users viewing this thread
1 guest


 
 
Adblock breaks this site