html - 堆栈上下文在 css 中究竟是如何工作的?
问题描述
正如您在图像中看到的,我具有以下结构:
#container {
background-color: yellow;
position: relative;
}
#child1 {
background-color: greenyellow;
position: absolute;
top: 0;
}
#child1a {
background-color: green;
z-index: 40;
}
#child2 {
position: absolute;
z-index: 1;
background-color: violet;
}
<div id="container">
<div id="child1">
<div id="child1a" />
</div>
<div id="child2" />
</div>
据我了解, child1 不应该创建新的堆叠上下文,因为我没有指定 z-index。因此 child1a 的父堆叠上下文应该与 child2 的父上下文相同,并且由于 child1a 的 z-index 大于 child2 的 z-index 应该高于 child2,我在这里缺少什么?
解决方案
推荐阅读
- flutter - 我如何从不同的类中调用 setState
- c++ - 为什么 C++ 中类字段的默认初始化需要调用析构函数?
- javascript - 当我在 D3.js 中通过 MySQL 提供多个根时,如何停止错误?
- java - 如何使用 iText7 正确地将 Java unicode 字符串转换为 PDF 字符串对象?
- flutter - 如何将 ListView 添加到列?
- javascript - 我将如何使它嵌入 roblox 链接
- jenkins - 如何使用 Jenkins API 卷曲 jenkins 实例中所有节点的名称?
- javascript - SharePoint 嵌入式 PowerBI 报表 - 如何从我们创建的另一个 Web 部件获取报表 JavaScript 对象
- r - 绘制多个网络,其中节点宽度在每个网络中缩放相同?
- arrays - 仅当列具有数据且特定列在 Google 表格中具有特定值时,才能从另一个工作表中自动填充列