Submenu positioning with relative position - HTML CSS CSS Layout

HTML CSS examples for CSS Layout:Relative Position

Description

Submenu positioning with relative position

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 {<!-- w w  w  .  j  a  v  a  2  s.  co  m-->
   background:none;
   height:51px;
   width:961px;
   margin:auto auto;
   padding:26px 0 0 34px;
}

.header ul {
   float:left;
   list-style:none;
   margin:0;
   overflow:visible;
   padding:10px 10px 0 0;
}

.header ul li {
   float:left;
   position:relative;
}

.header ul li a {
   color:Chartreuse;
   font-family:bevanregular;
   font-size:17px;
   font-weight:401;
   letter-spacing:.26em;
   line-height:31px;
   text-decoration:none;
   text-transform:uppercase;
   margin:176px 12px 0 12px;
}

.header ul li.selected a, .header ul li a:hover {
   color:yellow;
}

.header ul ul {
   display:none;
   position:absolute;
   top:100%;
   left:0;
   background:blue;
}

.header ul ul li {
   float:none;
}

.header>ul>li:hover>ul {
   display:block;
}
</style> 
 </head> 
 <body> 
  <div class="header"> 
   <ul> 
    <li> <a href="/">Lore</a>Lor</li> 
    <li> <a href="/teams">Lorem</a>Lor 
     <ul> 
      <li> <a href="#">Lo</a> </li> 
      <li> <a href="#">Lo</a> </li> 
      <li> <a href="#">Lor</a> </li> 
      <li> <a href="#">Lor</a> </li> 
     </ul> </li> 
    <li> <a href="/schedule">Lorem ip</a>Lor</li> 
    <li> <a href="/forms">Lorem</a>Lor</li> 
    <li> <a href="/sponsors">Lorem ip</a>Lor</li> 
    <li> <a href="/about-us">Lorem</a>Lor</li> 
    <li> <a href="/contact-us">Lorem i</a> </li> 
   </ul> 
  </div>  
 </body>
</html>

Related Tutorials