CSS responsive horizontal nav with sub nav below - HTML CSS CSS Layout

HTML CSS examples for CSS Layout:Responsive Layout

Description

CSS responsive horizontal nav with sub nav below

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 {<!--   www  . j  av a2s  .c  o m-->
   width:100%;
   position:relative;
}

#header ul.nav {
   width:100%;
   padding:14px 0;
   display:block;
   text-align:center;
   position:relative;
   border-top:2px solid Chartreuse;
   border-bottom:2px solid yellow;
}

#header ul.nav li {
   display:inline;
   text-align:center;
   position:relative;
}

#header ul.nav li a {
   display:inline-block;
   padding:0 2.5em;
   line-height:31px;
   font-size:15px;
}

#header ul.subnav {
   border-top:none;
   padding:11px 0;
   position:absolute;
   left:-1000em;
   z-index:1000;
   background:blue;
}

#header ul.nav li:hover ul.subnav {
   left:0px;
   top:11px;
}

#header ul.subnav li a {
   line-height:23px;
   font-size:13px;
}
</style> 
 </head> 
 <body> 
  <div id="header"> 
   <ul class="nav"> 
    <li> <a href="#">Lorem </a> 
     <ul class="nav subnav"> 
      <li> <a href="#">Lorem </a> </li> 
      <li> <a href="#">Lorem </a> </li> 
      <li> <a href="#">Lorem </a> </li> 
      <li> <a href="#">Lorem </a> </li> 
     </ul> </li> 
    <li> <a href="#">Lorem </a> </li> 
    <li> <a href="#">Lorem </a> </li> 
    <li> <a href="#">Lorem </a> 
     <ul class="nav subnav"> 
      <li> <a href="#">Lorem </a> </li> 
      <li> <a href="#">Lorem </a> </li> 
      <li> <a href="#">Lorem </a> </li> 
      <li> <a href="#">Lorem </a> </li> 
     </ul> </li> 
    <li> <a href="#">Lorem </a> </li> 
    <li> <a href="#">Lorem </a> </li> 
   </ul> 
  </div>  
 </body>
</html>

Related Tutorials