css - 重叠的 div

标签 css html

我需要 2 个重叠的 div,如下所示。

    ------------------------------------
   |                      |             |
   |   ------------------ |             |
   |  '                  '|             |
   |  '                  '|             |
   |  '                  '|             |
   |  '                  '|             |
   |  '                  '|             |
   |  '                  '|             |
   |  '                  '|             |
   |  --------------------|             |
   |  '                  '|             |
   |  '                  '|             |
   |   -------------------|             |
   |                      |             |
   |                      |             |
    ------------------------------------

但不知何故我无法得到它。 here is the place am fiddling out 谁能告诉我哪里出错了。

编辑 1: 我有一个左 div 和一个右 div。左边的 div 有重叠的 div。右边的 div 是一个普通的 div。我想你们中的大多数人都感到困惑,认为右边的 div 是重叠的,左边的 div 中有 2 个 div,我需要它们重叠。

抱歉打扰了大家。

最佳答案

我想你想要这样的东西:

html

<div class="parent">
  <div class="a"></div>
  <div class="b"></div>
</div>

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;
}

编辑:在你的例子中 parent = contentContainer, a/b = leftContainer/rightContainer

关于css - 重叠的 div,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3090289/

相关文章:

html - 想要使用 Bootstrap 将一个完整页面拆分为四个相同大小的 div

html - 如何对齐子导航并使其正确

html - 无法让 li 项占用 ul 内的所有空间

html - 使用 CSS 在一行中获取 mailchimp 表单

javascript - 在 html 表格的 foreach 绑定(bind)内,是否可以通过 knockout 将数据绑定(bind)到选择下拉列表?

javascript - 与 Karma 集成测试

html - 在移动 View 上切换 Bootstrap 列

javascript - 内存游戏星级评分错误(未捕获类型错误 : Cannot read property 'remove' of undefined)

html - CSS 嵌套选择器,只选择第 2 级,忽略第 1 级和第 3 级及以上

css - CSS 背景中的 Symfony2 图像资源