CSS Property Value How to - top: 100px; Stack div elements with top offset








Question

We would like to know how to top: 100px; Stack div elements with top offset.

Answer


<!DOCTYPE html>
<html>
<head>
<style type='text/css'>
div.pan {<!--  ww w  .j a  v a2s  .c  om-->
  position: absolute;
  z-index: -1;
  left: 0;
  top: 0;
  height: 100px;
  width: 100%;
  background: red;
}

div.row2 {
  top: 100px;
  background: blue;
}
</style>
</head>
<body>
  <div class="pan row1"></div>
  <div class="pan row2"></div>
</body>
</html>

The code above is rendered as follows: