【问题标题】:CSS Z-index not overlapping [duplicate]CSS Z-index不重叠[重复]
【发布时间】:2018-09-03 04:50:50
【问题描述】:

所以我试图用 CSS 自定义一个网站,但我不能在 this element 下重叠 this image。 代码:

body#bodyDefault > form > div > table > tbody::after {
    pointer-events: none;
    content:' ';
    position: absolute;
    right: 0;
    top: 0;
    z-index: 20;
    background-image: url('');
    height: 200px;
    width: 200px;
    background-size: 200px;
}
body#bodyDefault > form > div > table > tbody > tr:nth-child(2) {
    z-index: 50;
}

我试图通过将图像隐藏在 tr 元素下来剪切图像的多余部分。

【问题讨论】:

  • 你能分享你的代码吗
  • 你试过什么?你能分享一下,我们会解决的。
  • 我添加了代码
  • 你能不能也显示你的html

标签: css z-index overlap


【解决方案1】:

使用position: absolute/relative;body#bodyDefault > form > div > table > tbody > tr:nth-child(2)

为什么?

z-index 没有position: absolute/relative; 就无法工作

例如:

body#bodyDefault > form > div > table > tbody > tr:nth-child(2) {
    z-index: 50;
    position: absolute;// or relative
}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2021-11-28
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-01-25
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多