Changing position of sublists of a dropdown menu - HTML CSS CSS Layout

HTML CSS examples for CSS Layout:Position

Description

Changing position of sublists of a dropdown menu

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">
.menu {<!--from  w  w w .  j  a v a 2 s.co  m-->
   border:none;
   border:0px;
   margin:0px;
   padding:0px;
   font:68.6% "Lucida Sans Unicode", "Bitstream Vera Sans", "Trebuchet Unicode MS", "Lucida Grande", Verdana, Helvetica, sans-serif;
   font-size:15px;
   font-weight:bold;
   float:right;
   width:auto;
}

.menu ul {
   background:Chartreuse;
   line-height:3.0em;
   list-style:none;
   margin:0;
   padding:0px;
}

.menu li {
   float:left;
   padding:0px;
}

.menu li a {
   background:yellow url('https://www.java2s.com/style/demo/Google-Chrome.png') bottom right no-repeat;
   color:blue;
   display:block;
   font-weight:normal;
   line-height:3.0em;
   margin:0px;
   padding:0px 26px;
   text-align:center;
   text-decoration:none;
}

.menu li a:hover, .menu ul li:hover a {
   background:pink bottom center no-repeat;
   color:OrangeRed;
   text-decoration:none;
}

.menu li ul {
   background:grey;
   display:block;
   float:left;
   height:auto;
   padding:0px;
   margin:0px;
   border-style:solid;
   border-color:BlueViolet;
   position:absolute;
   width:auto;
   z-index:201;
}

.menu li:hover ul {
   display:block;
}

.menu li li {
   background:bottom left no-repeat;
   display:block;
   float:none;
   margin:0px;
   padding:0px;
   width:226px;
   color:Chartreuse;
}

.menu li:hover li a {
   background:none;
   color:yellow;
}

.menu li ul {
   display:block;
   margin-left:-131px;
}

.menu li ul a {
   display:block;
   line-height:36px;
   font-size:13px;
   font-style:normal;
   margin:0px;
   padding:0px 11px 0px 16px;
   text-align:left;
}

.menu li ul a:hover, .menu li ul li:hover a {
   background:blue left no-repeat;
   border:0px;
   color:pink;
   text-decoration:none;
}

.menu p {
   clear:left;
}
</style> 
 </head> 
 <body> 
  <div class="menu"> 
   <ul> 
    <li> <a href="#">Lorem </a> 
     <ul> 
      <li> <a href="#">Lorem ips</a> </li> 
      <li> <a href="#">Lorem ips</a> </li> 
      <li> <a href="#">Lorem ips</a> </li> 
     </ul> </li> 
   </ul> 
  </div>  
 </body>
</html>

Related Tutorials