Change the background color of up triangle when hovering a submenu item - HTML CSS CSS Widget

HTML CSS examples for CSS Widget:Menu Hover

Description

Change the background color of up triangle when hovering a submenu item

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 {<!-- www.ja  v  a2 s  . co m-->
   position: relative;
   background: linear-gradient(red, #7f6b00);
   background: -webkit-linear-gradient(red, #7f6b00);
   background: -o-linear-gradient(red, #7f6b00);
   background: -ms-linear-gradient(red, #7f6b00);
   background: -moz-linear-gradient(red, #7f6b00);
   border-bottom: 3px solid #665600;
   color: #FFF;
   padding: 8px 8px;
   box-shadow: 0 8px 6px -6px #333;
   -webkit-box-shadow: 0 8px 6px -6px #333;
   -o-box-shadow: 0 8px 6px -6px #333;
   -ms-box-shadow: 0 8px 6px -6px #333;
   -moz-box-shadow: 0 8px 6px -6px #333;
}

#nav ul {
   list-style-type: none;
   text-align: center;
}

#nav ul li {
   display: inline-block;
}

#nav ul li a {
   text-decoration: none;
   color: #FFF;
   padding: 8px 12px;
}

#nav ul li a:hover {
   color: #FFF;
   border-bottom: 3px solid #ccac00;
   background: linear-gradient(pink, blue);
   background: -webkit-linear-gradient(pink, blue);
   background: -o-linear-gradient(pink, blue);
   background: -ms-linear-gradient(pink, blue);
   background: -moz-linear-gradient(pink, blue);
}

#nav .submenu {
   display: none;
}

#nav li:hover .submenu {
   display: block;
}

#nav .submenu {
   background: linear-gradient(red, #7f6b00);
   background: -webkit-linear-gradient(red, #7f6b00);
   background: -o-linear-gradient(red, #7f6b00);
   background: -ms-linear-gradient(red, #7f6b00);
   background: -moz-linear-gradient(red, #7f6b00);
   border-bottom: 3px solid #665600;
   position: absolute;
   margin-top: 10px;
}

#nav .submenu li:first-child:before {
   content: "";
   position: absolute;
   width: 0;
   height: 0;
   border-bottom: 22px solid red;
   border-left: 11px solid transparent;
   border-right: 11px solid transparent;
   margin: -12px 0 0 -0px;
}

#nav .submenu li:first-child:hover:before {
   border-bottom: 22px solid pink;
}

#nav .submenu li {
   display: block;
   text-align: left;
}

#nav .submenu li a {
   display: block;
   border-bottom: 1px solid #665600;
   padding: 8px 30px;
}

#nav .submenu li a:hover {
   color: #FFF;
   border-bottom: 1px solid #ccac00;
   background: linear-gradient(pink, blue);
   background: -webkit-linear-gradient(pink, blue);
   background: -o-linear-gradient(pink, blue);
   background: -ms-linear-gradient(pink, blue);
   background: -moz-linear-gradient(pink, blue);
}

      </style> 
 </head> 
 <body> 
  <div id="nav"> 
   <ul> 
    <li> <a href="#">Main</a> 
     <ul class="submenu"> 
      <li> <a href="#">Sub 1</a> </li> 
      <li> <a href="#">Sub 2</a> </li> 
      <li> <a href="#">Sub 3</a> </li> 
      <li> <a href="#">Sub 4</a> </li> 
     </ul> </li> 
   </ul> 
  </div>  
 </body>
</html>

Related Tutorials