CSS Dropdown Menu Without Fixed Width - HTML CSS CSS Widget

HTML CSS examples for CSS Widget:Menu Dropdown

Description

CSS Dropdown Menu Without Fixed Width

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 ul<!--from www . ja  v a2s  . c  om-->
 {
   padding:0px;
   margin:0px;
   list-style:none;
   position:relative;
   display:block;
   font-family:'Trebuchet MS', Helvetica, sans-serif;
   font-size:15px;
   height:26px;
}

nav ul:after {
   content:"";
   clear:both;
   display:block;
}

nav ul ul
 {
   display:none;
   position:absolute;
}

nav ul li {
   float:left;
   cursor:pointer;
   border-left:2px solid Chartreuse;
   height:26px;
   position:relative;
}

nav ul li div
 {
   margin-top:6px;
   margin-left:11px;
   margin-right:11px;
   height:100%;
   padding:0px;
   float:left;
}

nav ul li:hover {
   background-color:yellow;
   color:blue;
}

nav ul li:hover>ul {
   display:block;
   position:absolute;
   top:26px;
   z-index:2;
   list-style-type:none;
   padding:0;
   margin:0;
   left:0;
}

nav ul ul li
 {
   background-color:pink;
   border-bottom:2px solid OrangeRed;
   width:100%;
   white-space:nowrap;
}

nav ul ul li:hover
 {
   color:grey;
}
</style> 
 </head> 
 <body> 
  <div style="height: 100%; float: right; margin: 0; padding: 0; "> 
   <nav> 
    <ul> 
     <li> <img src="https://www.java2s.com/style/demo/Firefox.png" id="vulcanUIHelp" style="margin-top: 5px; margin-right: 10px; margin-left: 10px;" alt="" width="16" height="16" title="Get UI help"> </li> 
     <li> 
      <div id="configure">
        Lorem ipsum 
      </div> 
      <ul> 
       <li> 
        <div id="confmbpolicy">
          Lorem ipsum dolor 
        </div> </li> 
       <li> 
        <div>
          Lorem ipsum 
        </div> </li> 
      </ul> </li> 
     <li> 
      <div id="settingsButton" title="Change system settings">
        Lorem ipsum dolor 
      </div> </li> 
     <li> 
      <div id="optionsLink" title="Open or close options window">
        Lorem ips 
      </div> </li> 
     <li> 
      <div id="help" title="Interactvely build a query">
        Lorem ipsum d 
      </div> </li> 
     <li style="border-right: 0;"> 
      <div id="logoutButton" title="Logout and close this window">
        Lorem ip 
      </div> </li> 
    </ul> 
   </nav> 
  </div>  
 </body>
</html>

Related Tutorials