重叠div

Cha*_*nya 9 html css

我需要2个重叠的div,看起来像下面的那个.

    ------------------------------------
   |                      |             |
   |   ------------------ |             |
   |  '                  '|             |
   |  '                  '|             |
   |  '                  '|             |
   |  '                  '|             |
   |  '                  '|             |
   |  '                  '|             |
   |  '                  '|             |
   |  --------------------|             |
   |  '                  '|             |
   |  '                  '|             |
   |   -------------------|             |
   |                      |             |
   |                      |             |
    ------------------------------------
Run Code Online (Sandbox Code Playgroud)

但不知怎的,我无法得到它.这里是摆弄的地方 任何人都可以告诉我哪里出错了.

编辑1: 我有一个左div和一个右div.左边的div有重叠的div.右div是一个普通的div.我猜大多数人都很困惑,而正确的div是重叠的,左边有两个div我需要那些重叠.

很抱歉让大家迷惑.

Ben*_*owe 16

我想你想要这样的东西:

HTML

<div class="parent">
  <div class="a"></div>
  <div class="b"></div>
</div>
Run Code Online (Sandbox Code Playgroud)

CSS

.parent {
  position: relative;
}

.a {
  position: absolute;
  width: 100px;
  height: 100px;
  z-index: 100;
  background: red;
}

.b {
  position: absolute;
  width: 80px;
  height: 180px;
  z-index: 110;
  left: 10px;
  background: blue;
  top: 10px;
}
Run Code Online (Sandbox Code Playgroud)

编辑:在您的情况下,parent = contentContainer,a/b = leftContainer/rightContainer