block by EE2dev 5529ba6e6abd39a1fe6293b22f106222

stacking context

Full Screen

Built with blockbuilder.org

Example from the excellent article https://philipwalton.com/articles/what-no-one-told-you-about-z-index/

To look at layouts, do: * { background: #000 !important; color: #0f0 !important; outline: solid #f00 1px !important; }

index.html

<!DOCTYPE html>
<head>
  <meta charset="utf-8">
  <style>
    .red, .green, .blue {
      position: absolute;
      width: 100px;
      color: white;
      line-height: 100px;
      text-align: center;
    }

    .red {
      top: 20px;
      left: 20px;
      background: red;
    }

    .green {
      top: 60px;
      left: 60px;
      background: green;
    }

    .blue {
      top: 100px;
      left: 100px;
      background: blue;
    }

    /*
    * {
      background: #000 !important;
      color: #0f0 !important;
      outline: solid #f00 1px !important;
    }
    */
  </style>
</head>

<body>
  <div>
    <span class="red">Red</span>
  </div>
  <div>
    <span class="green">Green</span>
  </div>
  <div>
    <span class="blue">Blue</span>
  </div>
</body>