如何使用 CSS 将子级 div 压在父级 div 下面
我被压在父级 div 下面了
.parent {
position: relative;
width: 200px;
height: 200px;
background-color: #eee;
}
.child {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
background-color: #ccc;
z-index: -1;
}
在这个示例中,子级 div 的 z-index 值为 -1,比父级 div 的 z-index 值低,因此子级 div 会被父级 div 覆盖,看起来就像是被压在下面了。
原文地址: https://www.cveoy.top/t/topic/nj8B 著作权归作者所有。请勿转载和采集!