html - 2 个 div 之间重叠

标签 html css reactjs twitter-bootstrap

如何在两个div之间叠加一个div?

这就是我所拥有的

rn

这是我的代码

<Jumbotron style={{position: 'relative'}}>
//
</Jumbotron>
<section id="foo1">
<Container style={{position: 'absolute', zIndex: 1}}>
//
</Container  
</section>
<section id="foo2">
<div style={{position: relative}}>
//
</div>
</section>

这是我期望的结果

expected

最佳答案

将覆盖 div 放入另一个 div 内,并设置 position:absolute

这是你想要的吗?尝试demo enter image description here

<div class="test">

  <div class="div1">
   I'm div 1
  </div>

  <div class="div2">
   <div class="div-overlay">
    overlay div
   </div>
   I', div 2
  </div>

</div>

CSS

.test{
  border: 1px solid black;
}

.div1{
  position: relative;
  display: "inline";
  background: yellow;
  height: 50px;
}

.div2{
  position: relative;
  display: "inline";
  background: purple;
  height: 50px;
}

.div-overlay{
  position: absolute;
  left: 100px;
  top: -25px;
  display: "inline";
  background: red;
  height: 50px;
  width: 100px;
}

(我在 OP 发布有效图像链接并编辑帖子之前编写了此代码)

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

相关文章:

html - 如何使 &lt;textarea&gt; 使用剩余的可用高度

javascript - template 指令有效,但 templateUrl 无效。请提出建议?

html - 垂直滚动捕捉部分内的水平滚动捕捉部分,由于 ul 和 div 的原因,上方有空白空间

reactjs - 我如何解决 React+Material UI 中的这个错误

css - 使用 className={styles.nameOfClass} 时为 "Unresolved variable"

javascript - 加载时的路由不适用于我的 React native 应用程序

html - 将YouTube视频嵌入到较旧的移动浏览器中

javascript - 鼠标悬停更改 tr bgcolor 在 IE 中不起作用

javascript - 搜索多个用户的输入并显示其中最常用的词

jquery - 具有转换内容的图像悬停效果