html - Menubar on site not centering after many tries -
i have menubar on site that's not centering. i've tried text-align:center everywhere, played around margins , position, can't seem text aligned main title regardless of screen size. guys mind taking look?
<title>test</title> <link rel="stylesheet" type="text/css" href="style.css"> <link href='http://fonts.googleapis.com/css?family=lato:300,700' rel='stylesheet' type='text/css'> </head> <body> <h1 style="text-align: center;">test</h1> <div> <ul id="nav"> <li ><a href="#" style="color:rgb(56,162,188);">home</a></li> <li ><a href="#" style="color:rgb(123,176,26);">projects</a></li> <li ><a href="#" style="color:rgb(243,45,93);">resume</a></li> <li ><a href="#" style="color:rgb(234,49,20);">contact</a></li> <li ><a href="#" style="color:rgb(237,103,14);">about</a></li> </ul> </div>
css:
h1, h2, h3, h4, h5, h6 { color: #26363d; font-family: "lato", sans-serif; font-weight: 300; line-height: 1.3em; } h1 { font-size: 60; } h2 { font-size: 25px; } h3 { font-size: 21px; } h4 { font-size: 19px; } h5 { font-size: 17px; } h6 { font-size: 15px; } body { font-family: "lato", sans-serif; background-image: url("background.png"); } #nav { float: left; width: 100% !important; margin: 0 auto; padding: 0; list-style: none; } #nav li { float: left; } #nav ul li { display: inline; } #nav li { display: block; padding: 8px 15px; text-decoration: none; font-weight: bold; border-right: 1px solid #ccc; } #nav li a:hover { color: #c00; }
you using float: left;
, width: 100%
wrong need remove 100% width, can use margin: auto;
, don't need float: left;
need menu bar centered
also you'll need fixed width #nav
can use margin: auto;
horizontal centering, , when add elements, change width of #nav
.
as of i've kept 550px
can change accordingly, css i've changed in #nav
#nav { width: 550px; margin: auto; padding: 0; list-style: none; }
Comments
Post a Comment