【问题标题】:z-index doesn't work correctly with all layerz-index 不适用于所有图层
【发布时间】:2019-08-18 14:50:11
【问题描述】:

我想用 HTML + CSS 做简单的动画。有人认为像进度条。 我有背景 - #mid。 我有“酒吧”的表格 - #kingIcon 我有内容“栏”-#kingIconBack kingIcon 和 mid 工作正常。 kingIcon 在中间,具有正确的不透明度。但是内容栏——kingIconBack 覆盖所有

我尝试改变位置。

CSS 
#mid{
    width: 60%;
    background-color: rgb(59, 194, 153);
    float: left;
    z-index: 3;
    position: relative;
}


#kingIcon{
    margin-top: 20px;
    z-index: 5;
    width: 60%;
    position: relative;
    left: 20%;

}

#kingIconBack{
    z-index: 4;
    position: absolute;
    top: 0%;

}


HTML

<div id="mid">
          <div id="kingIcon"><img src="krolPrzezroczysty.png" width="100%"  alt="kingIcon">
                    <div id="kingIconBack"><img src="gradient.png" width="141.2%"  > </div>
                  </div>


        </div>

内容栏-kingIcon后盖全部

【问题讨论】:

  • 它是覆盖整个页面,还是覆盖所有父页面?尝试在您的 kingIconBack 中定义一个宽度。
  • 整个页面。也有宽度。
  • 您正在为 kingIconBack 定义图像中 141% 的宽度。对吗?
  • 是的,因为我在它旁边放了层。

标签: html css position z-index


【解决方案1】:

我意识到kingIconBack 不能是kingIcon 的孩子。

感谢所有cmets!

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2019-04-15
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-01-21
    • 1970-01-01
    • 2022-11-25
    相关资源
    最近更新 更多