Search code examples
cssnavigationcenteringalignment

Centering my navigation menu links


I just can't seem to figure this out. I've tried text-align: center; , display: inline-block and more but I just cant figure out how to center my navigation within the #menu-bottom-nav.

CSS

#menu-bottom-nav { width: 600px; height: 70px; margin: 0px auto;}
#menu-bottom-nav li { list-style-type: none; float: left; margin-right: 20px;}

Any help is appreciated.

enter image description here


Solution

  • Try this out:

    <!DOCTYPE>
    
    <html>
    <head>
        <title>Test</title>
    
        <style type="text/css">
            #menu-bottom-nav {
                margin: 0;
                padding: 0;
                width: 600px;
                text-align: center;
                border: 1px solid #000;
            }
    
            #menu-bottom-nav li {
                list-style-type: none;
                margin-right: 20px;
                border: 1px solid #ff0000;
                display: inline-block;
                *display: inline;
                zoom: 1;
            }
        </style>
    </head>
    <body>
        <ul id="menu-bottom-nav">
            <li>Test</li>
            <li>Test2</li>
            <li>Test3</li>
        </ul>
    </body>
    </html>