html - 如何使子元素高于子元素z-index?
问题描述
所有元素都应该是绝对位置!
需要实现的是元素“child1”(z-index:3;)在“child2”(z-index:2)之上,两者都应该在父div中(z-index:1;)。
如何使这成为可能?
代码:
#parent {
width: 300px;
height: 300px;
background: blue;
position: absolute;
top: 30px;
left: 30px;
z-index: 1;
}
#child1 {
width: 150px;
height: 150px;
background: red;
position: absolute;
top: 80px;
left: 80px;
z-index: 3;
}
#child2 {
width: 100px;
height: 100px;
background: green;
position: absolute;
top: -30px;
left: -30px;
z-index: 2;
<div id="parent">
<div id="child1">
<div id="child2"></div>
</div>
</div>
解决方案
推荐阅读
- python - pip3 install grpcio 在 Raspberri Pi 3(Ubuntu Server 20.04 LTS)上失败
- python-3.x - 忽略零值数据点的 Scipy 中值过滤器?
- azure-cognitive-search - Querytype=Full 并且搜索停用词不返回任何结果
- java - 我无法使用毕加索库显示图片
- javascript - JavaScript - 从 Promise 对象获取数据的问题
- laravel - PHPUnit 测试:写入/从 Memcached 检索的问题
- solidity - 如何在 ton-solidity 合约中返回映射?
- postgresql - 在 Postgres 中获取每个日历月的最后一个值
- php - 不断给出错误未定义的变量框架路由[OPEN]
- css - 为什么我的 React 组件在导入到另一个组件时具有不同的 css 属性?