Page Widget How to - Click to trigger dropdown menu








Question

We would like to know how to click to trigger dropdown menu.

Answer


<!DOCTYPE html>
<html>
<head>
<style type='text/css'>
ul {<!--from  w  ww .jav  a  2  s.  c o m-->
  display: none;
  position: relative;
  top: -55px;
  padding: 55px 0 0 0;
  margin: 0;
}

ul:hover {
  display: block;
}

li {
  background: #ddd;
  padding: 10px;
  list-style: none;
  .
}

li:hover {
  background: #eee;
  cursor: pointer;
}

#button {
  display: inline-block;
  padding: 10px;
  background: #ccc;
  color: white;
}

#dd {
  display: inline-block;
}

#dd:active ul {
  display: block;
}

#dd:aactive ul:hover {
  display: block;
}

#dd:active #button {
  display: inline-block;
  padding: 10px;
  background: #ccc;
  color: white;
}
</style>
</head>
<body>
  <div id="dd">
    <a href="#" id="button">Select Language</a>
    <ul>
      <li>English</li>
      <li>French</li>
      <li>German</li>
      <li>Spanish</li>
    </ul>
  </div>
</body>
</html>

The code above is rendered as follows: