center an unordered list inside a fixed position div with 100% width - HTML CSS CSS Layout

HTML CSS examples for CSS Layout:Fixed Position

Description

center an unordered list inside a fixed position div with 100% width

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">
nav {<!--   w w w.ja v a  2  s . c o  m-->
   position:fixed;
   width:100%;
   background:Chartreuse;
}

nav ul {
   width:201px;
   margin:auto
}

nav ul li {
   display:inline-block;
   margin:6px;
}

nav ul li a {
   color:yellow;
}
</style> 
 </head> 
 <body> 
  <nav id="nav-bar"> 
   <ul> 
    <li> <a href="#">Lore</a> </li> 
    <li> <a href="#">Lore</a> </li> 
    <li> <a href="#">Lore</a> </li> 
    <li> <a href="#">Lore</a> </li> 
    <li> <a href="#">Lore</a> </li> 
   </ul> 
  </nav> 
  <div>
    Lorem ipsum do 
   <br>Lorem ipsum do 
   <br>Lorem ipsum do 
   <br>Lorem ipsum do 
   <br>Lorem ipsum do 
   <br>Lorem ipsum do 
   <br>Lorem ipsum do 
   <br>Lorem ipsum do 
   <br>Lorem ipsum do 
   <br>Lorem ipsum do 
   <br>Lorem ipsum do 
   <br>Lorem ipsum do 
   <br>Lorem ipsum do 
   <br>Lorem ipsum do 
   <br>Lorem ipsum do 
   <br>Lorem ipsum do 
   <br>Lorem ipsum do 
   <br>Lorem ipsum do 
   <br>Lorem ipsum do 
   <br>Lorem ipsum do 
   <br>Lorem ipsum do 
   <br>Lorem ipsum do 
   <br>Lorem ipsum do 
   <br>Lorem ipsum do 
   <br>Lorem ipsum do 
   <br>Lorem ipsum do 
   <br>Lorem ipsum do 
   <br>Lorem ipsum do 
   <br>Lorem ipsum do 
   <br>Lorem ipsum do 
   <br>Lorem ipsum do 
   <br>Lorem ipsum do 
   <br>Lorem ipsum do 
   <br>Lorem ipsum do 
   <br>Lorem ipsum do 
   <br>Lorem ipsum do 
   <br>Lorem ipsum do 
   <br>Lorem ipsum do 
   <br>Lorem ipsum do 
   <br>Lorem ipsum do 
   <br>Lorem ipsum do 
   <br>Lorem ipsum do 
   <br>Lorem ipsum do 
   <br>Lorem ipsum do 
   <br>Lorem ipsum do 
   <br>Lorem ipsum do 
   <br>Lorem ipsum do 
   <br>Lorem ipsum do 
   <br>Lorem ipsum do 
   <br>Lorem ipsum do 
   <br>Lorem ipsum do 
   <br>Lorem ipsum do 
   <br>Lorem ipsum do 
   <br>Lorem ipsum do 
   <br>Lorem ipsum do 
   <br>Lorem ipsum do 
   <br>Lorem ipsum do 
   <br>Lorem ipsum do 
   <br>Lorem ipsum do 
   <br>Lorem ipsum do 
   <br>Lorem ipsum do 
   <br> 
  </div>  
 </body>
</html>

Related Tutorials