javascript - 父级绝对 z-index 中的子级绝对位置

标签 javascript jquery html css

父绝对必须在子绝对之下 如何用css解决这个问题?

位置必须是绝对的。

    <div class="parent">
      <div class="child">child</div>
    </div>
    <div class="parent">
      <div class="child">child</div>
    </div>

My code is here

最佳答案

编辑这个类:

.child {
position: absolute;
right: -280px;   /* add this and remove left:0; */
top: 0;
text-align: center;
width: 280px;
height: 300px;
background: #0f0;
display: none;
z-index: 1;   /* add this to set child over the second parent */

jsfiddle

关于javascript - 父级绝对 z-index 中的子级绝对位置,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19334411/

相关文章:

javascript - 将 image/jpeg 作为 arraybuffer 或 blob 返回

javascript - 如何使用 Bootstrap 模态对话框并获取返回值?

jquery - ZIndex Windows 移动版

javascript - Crowdflower:如何包含自定义 HTML?

javascript - 从 1 而不是 0 开始线性刻度 (D3.js)

javascript - 无法将值发布到程序

html - 所有 html Canvas 形状都被赋予最后添加的对象的颜色

javascript - 在 TextArea HTML 中作为标题标签

javascript - 在测验应用程序中设置计时器

jquery 否决 css