<header>
  <div class="menu">menu box<br/>z-index: 999</div>
</header>
<main>
  <div class="main-box">
    <p>No z-index</p>
    <p>This div covers menu box with high z-index because they are both in different stacking contexts (both their parent have position relative and z-index set to 1). And since div with no z-index is later in the document it will be rendered above the menu.</p>
    <p>Try to change z-index values or remove it to see what happens.</p>
  </div>
</main>
body {
  margin: 0;
  font-family: sans-serif;
}

header {
  background: #0087FE;
  height: 4rem;
  position: relative;
  z-index: 1;
}

main {
  position: relative;
  z-index: 1;
}

.menu {
  width: 10rem;
  height: 15rem;
  background-color: white;
  box-shadow: 0 3px 10px 0 rgba(0,0,0,0.5);
  z-index: 999;
  position: relative;
  text-align: center;
  padding: 2rem;
}

.main-box {
  width: 80vw;
  margin: 2rem auto;
  height: 20rem;
  background-color: #E0EEF0;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  padding: 1rem;
  // position: relative;
}
View Compiled

External CSS

This Pen doesn't use any external CSS resources.

External JavaScript

This Pen doesn't use any external JavaScript resources.