Page Widget How to - Create drop down menu








Question

We would like to know how to create drop down menu.

Answer


<!DOCTYPE html>
<html lang="en">
<head>
<style type="text/css">
ul {<!--   w ww .jav  a 2  s  . c  om-->
  padding: 0;
  list-style: none;
}

ul li {
  width: 100px;
  text-align: center;
  background: #5287a6;
  font-weight: bold;
}

ul li a {
  padding: 5px;
  display: block;
  color: #ffffff;
  text-decoration: none;
}

ul li a:hover {
  text-decoration: underline;
}

ul li ul {
  display: none;
}

ul li:hover ul {
  display: block;
}
</style>
</head>
<body>
  <h1>A Simple Drop Down Menu</h1>
  <ul>
    <li><a href="#">Click Me</a>
      <ul>
        <li><a href="#">Item 1</a></li>
        <li><a href="#">Item 2</a></li>
        <li><a href="#">Item 3</a></li>
      </ul></li>
  </ul>
</body>
</html>

The code above is rendered as follows: