Page Widget How to - Create Nested background color








Question

We would like to know how to create Nested background color.

Answer


<!DOCTYPE html>
<html>
<head>
<style type='text/css'>
.Group, .Group1, .Group2, .Group3 {<!--from  ww w .j  a va  2s . c om-->
  background-color: transparent;
}

.Group:hover {
  background-color: yellow;
}

.Group1:hover {
  background-color: pink;
}

.Group2:hover {
  background-color: red;
}

.Group3:hover {
  background-color: orange;
}
</style>
</head>
<body>
  <div class="Group">
    root
    <div class="Group1">
      1st child
      <div class="Group2">
        2nd child
        <div class="Group3">3rd child</div>
      </div>
    </div>
    <div class="Group1">1st child</div>
  </div>
</body>
</html>

The code above is rendered as follows: