嵌套的绝对、固定和相对元素的 z-index 和宽度问题

z-index & width issue with nested absolute, fixed and relative elements

我正在使用 React 构建一个复杂的网络应用程序,我正在尝试找出处理复杂定位和分层情况的最聪明的方法。

我想知道我是否需要重新考虑我的整个结构或只是调整一些 css 值。

下面的代码解释了我的问题:

aside {
  position: absolute;
  top: 0;
  left: 0;
  width: 20%;
  height: 100vh;
  background: blue;
  color: white;
}
main {
  position: absolute;
  overflow: hidden;
  background-image: url('https://i.ytimg.com/vi/6sta6Gkpgcw/maxresdefault.jpg');
  background-size: cover;
  top: 0;
  left: 20%;
  width: 80%;
  height: 100vh
}
.page-wrap {
  position: relative;
  width: 100%;
  height: 100vh;
  overflow: auto;
}
.overlay {
  position: fixed;
  z-index: 1;
  padding: 40px;
  color: white;
  font-size: 24px;
  width: calc(80% - 80px);
  height: 100vh;
  background-color: rgba(0, 0, 0, .5);
}
ul {
  position: relative;
  z-index: 2;
  list-style: none;
  color: white;
  font-size: 24px;
  line-height: 2em;
  padding-top: 100vh;
}
ul li {
  display: inline-block;
  width: 200px;
  height: 200px;
  text-align: center;
  padding: 20px;
  background: #ccc;
  color: red;
  margin: 50px;
}
button {
  padding: 10px 30px;
  background: green;
  color: white;
  font-size: 24px;
}
<aside>
  SIDEBAR
</aside>
<main>
  <section class="page-wrap">
    <div class="overlay">
      <button>
        This needs to be clickable even though the list is on top
      </button>
      <div>
        <h1>My issues here are:</h1>
        <ol>
          <li>the green button is covered (disabled) by the list</li>
          <li>the overlay covers the scrollbar on its parent page-wrap section</li>
        </ol>
      </div>
    </div>
    <ul>
      <li>Item</li>
      <li>Item</li>
      <li>Item</li>
      <li>Item</li>
      <li>Item</li>
      <li>6</li>
      <li>Item</li>
      <li>Item</li>
      <li>Item</li>
      <li>Item</li>
      <li>Item</li>
      <li>Item</li>
      <li>Item</li>
      <li>Item</li>
      <li>Item</li>
      <li>Item</li>
      <li>Item</li>
      <li>Item</li>
      <li>Item</li>
      <li>Item</li>
      <li>Item</li>
      <li>Item</li>
      <li>vew</li>
      <li>Item</li>
    </ul>
  </section>
</main>

FIDDLE

我的解决方案是重组 DOM 使正文溢出。我一直试图避免这种情况,因为它是一个包含大量组件和页面的大型 Web 应用程序,其中许多组件和页面遭受了附带损害,但最终,它解决了我的问题。