CSS Property Value How to - z-index: 1;








Question

We would like to know how to z-index: 1;.

Answer


<!DOCTYPE html>
<html lang="en">
<head>
<style type="text/css">
div {<!--from ww w  .j  a  va  2 s . c  om-->
  top: 30px;
  left: 30px;
  width: 100px;
  height: 100px;
  position: absolute;
}

div.red {
  background: #ff0000;
  z-index: 1;
}

div.green {
  background: #00ff00;
  z-index: 2;
}

div.blue {
  background: #0000ff;
  z-index: 3;
}
</style>
</head>
<body>
  <div class="red">
    <div class="green">
      <div class="blue"></div>
    </div>
  </div>
</body>
</html>

The code above is rendered as follows: