Css 溢出的兄弟姐妹';孩子们要学会正确的方法
我有一个圆形div,代表白色圆圈和徽标。好像我想这样Css 溢出的兄弟姐妹';孩子们要学会正确的方法,css,css-position,z-index,Css,Css Position,Z Index,我有一个圆形div,代表白色圆圈和徽标。好像我想这样 <div class="whiteCircle"> <div class="image" style="background-image: url('https://www.postnl.nl/Images/marker-groen-PostNL_tcm10-72617.png?version=1');"></div> </div> .whiteCircle { width: 65
<div class="whiteCircle">
<div class="image" style="background-image: url('https://www.postnl.nl/Images/marker-groen-PostNL_tcm10-72617.png?version=1');"></div>
</div>
.whiteCircle {
width: 65px;
height: 65px;
background-color: white;
border-radius: 50px;
position: absolute;
left: 0;
right: 0;
margin: 0 auto;
}
双亲的位置看起来都不错,但是我想不出一个方法来将标题移到白盒上方。我玩了z-index的组合,但我读到不可能同时调整孩子的z-index和家长
我做错了什么?实现这一目标的正确途径是什么
1-从父div中删除z-index
。
2-将z-index
添加到白盒div中,我选择值20
3-绝对定位.text类,并确保其z索引大于20
css
body {
background-color: lightblue;
}
.whiteBox {
width: 65px;
height: 65px;
background-color: white;
border-radius: 50px;
position: absolute;
left: 0;
right: 0;
margin: 0 auto;
z-index:20;
}
.image {
text-align: center;
height: 100%;
background: no-repeat center center;
}
.container {
width: 275px;
height: 350px;
background-color: white;
margin: 0 auto;
position: absolute;
left: 0;
right: 0;
margin: 0 auto;
top: 38px
}
.text {
text-align: center;
z-index: 25;
position: absolute;
left: 35%;
}
1-从父div中删除z-index
。
2-将z-index
添加到白盒div中,我选择值20
3-绝对定位.text类,并确保其z索引大于20
css
body {
background-color: lightblue;
}
.whiteBox {
width: 65px;
height: 65px;
background-color: white;
border-radius: 50px;
position: absolute;
left: 0;
right: 0;
margin: 0 auto;
z-index:20;
}
.image {
text-align: center;
height: 100%;
background: no-repeat center center;
}
.container {
width: 275px;
height: 350px;
background-color: white;
margin: 0 auto;
position: absolute;
left: 0;
right: 0;
margin: 0 auto;
top: 38px
}
.text {
text-align: center;
z-index: 25;
position: absolute;
left: 35%;
}
在本例中,白框上方的“是否”表示“在顶部上方”?我将类名修改为更具描述性。我希望标题位于白色圆圈上方,但不希望徽标位于矩形框下方,whiteBox
上方的does“意思是”在顶部的does“在这种情况下,我将类名固定为更具描述性。我希望标题位于白色圆圈上方,但不希望徽标位于矩形框下方