Center pure CSS3 dropdown navigation menu bar - HTML CSS CSS Widget

HTML CSS examples for CSS Widget:Menu Dropdown

Description

Center pure CSS3 dropdown navigation menu 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">
* {<!--from   www .j  ava 2 s  .co  m-->
   margin:0;
   padding:0;
}

body {
   font-family:'Open Sans', sans-serif;
}

ul#dropdown {
   list-style:none;
   position:relative;
   left:51%;
   transform:translateX(-51%);
   display:inline-block;
}

ul#dropdown li {
   float:left;
   background:darkgrey;
}

ul#dropdown li a {
   display:inline-block;
   padding:21px 41px;
   color:Chartreuse;
   text-decoration:none;
   text-transform:uppercase;
   font-size:21px;
}

ul#dropdown li:hover {
   background:grey;
}

ul#dropdown>li:not(:last-child) {
   border-right:2px solid yellow;
}

ul#dropdown li ul {
   list-style:none;
   display:none;
   position:absolute;
   margin-top:0px;
}

ul#dropdown li:hover ul {
   display:block;
}

ul#dropdown li ul li {
   float:none;
   border:none;
   border-top:2px solid blue;
}
</style> 
 </head> 
 <body> 
  <nav> 
   <ul id="dropdown"> 
    <li> <a href="#">Lorem</a> </li> 
    <li> <a href="#">Lorem</a> </li> 
    <li> <a href="#">Lorem</a> 
     <ul> 
      <li> <a href="#">Lorem ipsum d</a> </li> 
      <li> <a href="#">Lorem ipsum d</a> </li> 
      <li> <a href="#">Lorem ipsum d</a> </li> 
     </ul> </li> 
    <li> <a href="#">Lorem</a> </li> 
    <li> <a href="#">Lorem</a> 
     <ul> 
      <li> <a href="#">Lorem ipsum d</a> </li> 
      <li> <a href="#">Lorem ipsum d</a> </li> 
      <li> <a href="#">Lorem ipsum d</a> </li> 
     </ul> </li> 
   </ul> 
  </nav>  
 </body>
</html>

Related Tutorials