Effect How to - Show div on hover and stay till mouseleave








Question

We would like to know how to show div on hover and stay till mouseleave.

Answer


<!DOCTYPE html>
<html>
<head>
<style type='text/css'>
.subNav {<!--  ww  w .  j  av  a  2 s.c  o m-->
  display: none;
}

li:hover .subNav {
  display: block;
}
</style>
</head>
<body>
  <ul>
    <li><span>test</span>
      <div class="subNav">
        <span>thing to be shown</span>
      </div></li>
  </ul>
</body>
</html>

The code above is rendered as follows: