Show and hide a "dropdown" menu on mouse hover - HTML CSS CSS Selector

HTML CSS examples for CSS Selector:hover

Description

Show and hide a "dropdown" menu on mouse hover

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>
<html>
<head>
<style>
div {background-color: green;}
div a {
    color: blue;
    padding: 15px;
    display:inline-block;
}
ul {<!--from   www.j  av  a2s. c om-->
  display: inline;
  margin: 0;
  padding: 0;
}
ul li {display: inline-block;}
ul li:hover {background: #555;}
ul li:hover ul {display: block;}
ul li ul {
  position: absolute;
  width: 200px;
  display: none;
}
ul li ul li {
  background: #555;
  display: block;
}
ul li ul li a {display:block !important;}
ul li ul li:hover {background: #666;}
</style>
</head>
<body>

<div>
  <a href="#">Useless Link</a>
  <ul>
    <li>
      <a href="#">Dropdown Link</a>
      <ul>
        <li><a href="#">Link 1</a></li>
        <li><a href="#">Link 2</a></li>
        <li><a href="#">Link 3</a></li>
      </ul>
    </li>
  </ul>
</div>

</body>
</html>

Related Tutorials