html - 当父级的父级也具有绝对位置时,z-index 在伪位置绝对位置
问题描述
我想要这样的顺序:红色下面,红色下面蓝色,橙色下面,橙色的伪应该在橙色和蓝色之间。所以起作用的是具有不同z-index
值的 div 的顺序:5、10 和 15(红色、蓝色和橙色框)。对于伪,我使用了比z-index
橙色更小的,但蓝色更大,并希望它低于橙色但高于蓝色框。有些东西不起作用。这些position
值必须是这样的,也许这些position
值的组合z-index
是错误的。有任何想法吗?
.wrapper {
background-color: lightcoral;
border: 5px solid #650c0c;
height: 300px;
position: relative;
width: 500px;
z-index: 5;
}
.box-absolute {
position: absolute;
left: 0;
top: 20px;
background-color: lightblue;
border: 5px solid #235e71;
width: 300px;
height: 300px;
z-index: 10;
}
.box-child {
border: 5px solid #cc8400;
background-color: orange;
width: 150px;
height: 200px;
position: relative;
z-index: 15;
}
.box-child::before {
content: 'between orange and blue';
position: absolute;
border: 3px dashed #116e11;
width: 150px;
height: 50px;
background-color: lightgreen;
z-index: 14;
top: -15px;
left: 20px
}
<div class="wrapper">
below all
<div class="box-absolute">
above red but below orange+pseudo
<div class="box-child">
above all
</div>
</div>
</div>
解决方案
推荐阅读
- java - 策略模式是否比 switch 语句产生更多开销?
- r - 如何在 R 中的另一个向量元素中按次重复向量元素?
- c# - 将不同类别作为财产的最佳方法
- rest - 从 Go 代码使用 API 时出现 401 错误,而 cURL 运行良好
- reactjs - 如何在 React 中添加一个可以支持数学方程式的 markdown 编辑器?
- c# - Xamarin 从列表 ObservableCollection 和列表视图表单中删除项目
- javascript - 如何在我的项目中正确重新计算停止和恢复动画计算
- python - 表有多个主键 Django
- sqlite - 从 SQLite 数据库中检索 Int 值
- mysql - Laravel 多次更新慢