• Jetzt anmelden. Es dauert nur 2 Minuten und ist kostenlos!

Frage How to use a click event instead of :hover

Floland

Neues Mitglied
Hello Experts,

how can i change the :hover to a click event ?

Code:
<!DOCTYPE html>
<html lang="de-DE">
<head>
<style>

ul{
  list-style-type: none;
  width: relative;
  background-color: #000;
  position: fixed;
  height: 100%;
  overflow: auto;
}
li a {
  display: block;
  color: #FFD166;
  padding: 5% 1vmax 5% 15%;
  font-size: 2vmax;
}
li a.active {
  background-color: #ffdb00;
  color: black;
}

ul li {
  display: block;
  position: relative;
}

li ul 
{ 
  display: none; 
}

ul li a {
  display: block;
  padding: 1em;
  white-space: nowrap;
  color: #fff;
}

ul li a:hover 
{ 
  background: #2c3e50; 
}

li:hover > ul {
  display: block;
  position: relative;
}

li:hover li 
{ 
  padding-left: 2em;
}

ul ul ul {
  bottom: 100%;
}

</style>
<title>Sample</title>

</head>
<body>

<ul class="navigation">
  <li><a href="#">1</a>
    <ul>
      <li><a href="#">1.1</a>
        <ul>
          <li><a href="#">1.1.1</a></li>
          <li><a href="#">1.1.2</a></li>
        </ul>
      </li>
      <li><a href="#">1.2</a>
        <ul>
          <li><a href="#">1.2.1</a></li>
          <li><a href="#">1.2.2</a></li>
        </ul>
      </li>
      <li><a href="#">1.3</a></li>
    </ul>
  </li>
</ul>

</body>
</html>

Thank you!
Florian
 
Zuletzt bearbeitet:
Zurück
Oben