Centered navbar elements with dropdown menu items - HTML CSS CSS Widget

HTML CSS examples for CSS Widget:Menu Dropdown

Description

Centered navbar elements with dropdown menu items

Demo Code

ResultView the demo in separate window

<html lang="en">
 <head> 
  <meta name="viewport" content="width=device-width, initial-scale=1"> 
  <style id="compiled-css" type="text/css">
.topnav {<!--from www .j av a  2s  . c  o m-->
   list-style-type:none;
   margin:0 auto;
   padding:0;
   overflow:hidden;
   background-color:Chartreuse;
   text-align:center;
   align-items:center;
}

.topnav ul {
   list-style-type:none;
   margin:0 auto;
   display:inline-block;
}

.topnav li {
   float:left;
}

.topnav li a, .dropbtn {
   display:inline-block;
   color:yellow;
   text-align:center;
   padding:15px 17px;
   text-decoration:none;
   width:100px;
}

.topnav li a:hover, .dropdown:hover .dropbtn {
   background-color:blue;
}

li.dropdown {
   display:inline-block;
}

.dropdown-content {
   display:none;
   position:absolute;
   background-color:pink;
   min-width:161px;
   box-shadow:0px 9px 17px 0px OrangeRed;
   z-index:2;
}

.topnav .dropdown-content a {
   color:grey;
   padding:13px 17px;
   text-decoration:none;
   display:block;
   text-align:left;
}

.topnav .dropdown-content a:hover {
   background-color:BlueViolet;
}

.dropdown:hover .dropdown-content {
   display:block;
}
</style> 
 </head> 
 <body> 
  <div class="topnav"> 
   <ul> 
    <li> <a class="active" href="index.html">Lore</a> </li> 
    <li class="dropdown"> <a href="javascript:void(0)" class="dropbtn">Lorem ip</a> 
     <div class="dropdown-content"> 
      <a href="#">Lorem ips</a> 
      <a href="#">Lorem i</a> 
      <a href="#">Lorem ipsum</a> 
      <a href="#">Lorem ipsum dolor sit</a> 
      <a href="#">Lorem ipsum</a> 
     </div> </li> 
    <li class="dropdown"> <a href="javascript:void(0)" class="dropbtn">Lorem </a> 
     <div class="dropdown-content"> 
      <a href="#">Lorem</a> 
      <a href="#">Lorem i</a> 
      <a href="#">Lorem </a> 
      <a href="#">Lore</a> 
      <a href="#">Lo</a> 
      <a href="#">Lore</a> 
      <a href="#">Lorem ips</a> 
      <a href="#">Lorem ip</a> 
      <a href="#">Lor</a> 
     </div> </li> 
    <li> <a href="deals.html">Lorem</a> </li> 
   </ul> 
  </div>  
 </body>
</html>

Related Tutorials