关于z-index的问题
<!DOCTYPE html>
<html>
<head>
<title>demo</title>
<meta charset="utf-8">
<style type="text/css">
.main{
width: 500px;
height: 500px;
position: relative;
left: 200px;
top: 200px;
background-color: #CCCCCC;
}
.body1{
width: 200px;
height: 200px;
background-color: white;
position: absolute;
left: 50%;
top:50%;
transform: translate(-50%,-50%);
}
.body2{
width: 200px;
height: 200px;
background-color: yellow;
position: absolute;
left: 50%;
top:50%;
transform: translate(-50%,-50%);
z-index: 10;
}
.circle{
width:100px;
height: 100px;
border-radius: 50% 50%;
background-color: blue;
position: absolute;
left: 60px;
z-index: 20;
}
</style>
</head>
<body>
<div class='main'>
<div class='body1'>
<div class='circle'></div>
</div>
<div class='body2'></div>
</div>
</body>
</html>
问题描述:
为什么body2设置了z-index为10,body1的子div--circle设置了z-index为20,最后还是被body1盖住了?
17
收起
正在回答 回答被采纳积分+1
Python全栈工程师2020
- 参与学习 人
- 提交作业 5288 份
- 解答问题 2433 个
Facebook曾声称“只招全栈工程师”!全栈用人需求猛增,市面人才紧缺。 0基础进击Python全栈开发,诱人薪资在前方!
了解课程


恭喜解决一个难题,获得1积分~
来为老师/同学的回答评分吧
0 星