Trouble centering fixed navigation bar - HTML CSS CSS Widget

HTML CSS examples for CSS Widget:Nav bar alignment

Description

Trouble centering fixed navigation bar

Demo Code

ResultView the demo in separate window

<html>
 <head> 
  <meta name="viewport" content="width=device-width, initial-scale=1"> 
  <style id="compiled-css" type="text/css">
#header {<!-- ww w.  j a va2 s.  c  o  m-->
   z-index:2;
   width:100%;
   height:81px;
   position:fixed;
   background-color:Chartreuse;
   display:block;
}

#nav {
   z-index:2;
   width:100%;
   margin-top:21px;
   display:block;
   position:fixed;
   text-align:center;
}

#nav ul {
   list-style:none;
   display:block;
   margin:0 auto;
   width:81%;
   height:51px;
   background-color:yellow;
}

#nav li {
   margin-top:10px;
   float:left;
   padding-left:22px;
   display:block;
}
</style> 
 </head> 
 <body> 
  <header id="header"> 
   <nav id="nav"> 
    <ul> 
     <li> <a href="#slide1">Lorem</a> </li> 
     <li> <a href="#slide2">Lorem ips</a> </li> 
     <li> <a href="#slide3">Lorem i</a> </li> 
     <li> <a href="#slide4">Lorem i</a> </li> 
    </ul> 
   </nav> 
  </header>  
 </body>
</html>

Related Tutorials