Effect How to - Show div when another div is hover








Question

We would like to know how to show div when another div is hover.

Answer


<!DOCTYPE html>
<html>
<head>
<style type='text/css'>
#container>div {
  display: none
}<!--from   ww w  .j  a v  a 2s. c  o  m-->

#container>div:first-child {
  display: block
}

#container:hover>div {
  display: block
}
</style>
</head>
<body>
  <div id="container">
    <div>A</div>
    <div>B</div>
  </div>
</body>
</html>

The code above is rendered as follows: