Position unordered lists nav menu inside width: 100% div - HTML CSS CSS Layout

HTML CSS examples for CSS Layout:Position

Description

Position unordered lists nav menu inside width: 100% div

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">
ul.nav {<!--   ww w  .ja v  a2s  .c o m-->
   width:100%;
   margin:0 auto;
   padding:0;
   list-style:none;
   background-color:Chartreuse;
   text-align:center;
   font-family:sans-serif;
}

.nav li {
   display:inline-block;
   width:20%;
   margin:0;
   padding:0;
}

.nav a {
   text-align:center;
   padding:13px 0 14px 0;
   margin:0;
   border-right:2px solid yellow;
   display:block;
}

.nav a:hover {
   background:blue;
   border:none;
}

ul.nav li:first-child a {
   border-right:2px solid pink;
}

ul.nav li:last-child a {
   border:none;
}
</style> 
 </head> 
 <body> 
  <ul class="nav"> 
   <li> <a href="#">Lore</a> </li> 
   <li> <a href="#">Lorem</a> </li> 
   <li> <a href="#">Lorem i</a> </li> 
   <li> <a href="#">Lorem i</a> </li> 
   <li> <a href="#">Lorem i</a> </li> 
  </ul>  
 </body>
</html>

Related Tutorials