Create a nav with a drop-down that overlaps the main content - HTML CSS CSS Widget

HTML CSS examples for CSS Widget:Menu Dropdown

Description

Create a nav with a drop-down that overlaps the main content

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 {<!--from   w  w w .ja v  a  2  s. c om-->
   background-color:Chartreuse;
}

nav ul {
   list-style-type:none;
   margin:0;
   padding:0;
   overflow:hidden;
   background-color:yellow;
   width:49%;
   margin-left:auto;
   margin-right:auto;
}

#dropdown {
   background:red;
   width:38%;
   display:none;
   position:absolute;
}

#dropdown li, #dropdown li a {
   width:100%;
   text-align:left;
}

#overOns:hover {
   background-color:blue;
}

li:hover #dropdown {
   display:block;
   margin-left:0;
   margin-right:0;
}

nav li {
   float:left;
}

nav li a {
   font-family:arial;
   display:inline-block;
   color:pink;
   text-align:center;
   padding:22px 21px;
   text-decoration:none;
}

nav li input {
   margin:21px 6px;
}

nav li .active {
   background:OrangeRed;
}

nav li .active:hover {
   background-color:grey;
}

nav li a:hover {
   background-color:BlueViolet;
}
</style> 
 </head> 
 <body> 
  <nav> 
   <ul> 
    <li> <a class="active" href="home.html">Lore</a> </li> 
    <li> <a href="">Lorem i</a> </li> 
    <li> <a href="">Lorem ip</a> </li> 
    <li id="overOns"> <a href="">Lorem ip</a> 
     <ul id="dropdown"> 
      <li> <a href="">Lorem ips</a> </li> 
      <li> <a href="">Lorem i</a> </li> 
      <li> <a href="">Lor</a> </li> 
      <li> <a href="">Lorem ipsum dolor</a> </li> 
     </ul> </li> 
    <li> <a href=""> <i class="fa fa-user" aria-hidden="true"></i>Lorem ip</a> </li> 
    <li> <i class="fa fa-search" aria-hidden="true"></i> <input placeholder="Zoeken..." type="text"> </li> 
   </ul> 
  </nav>  
 </body>
</html>

Related Tutorials