【发布时间】:2018-07-30 22:59:34
【问题描述】:
我希望外环位于圆圈后面,但是当我尝试使用 z-index 时,它不起作用。什么都不做。我做了2个环,一个环在没有顶部的圆圈顶部,另一个在圆圈后面我就是不能移动它我不知道为什么。
:root{
--size:200px;
}
#background {
width:100%;
height:100%;
position:absolute;
top:0;
left:0;
background: linear-gradient(-23.5deg, #000033, #00001a);
z-index:-2;
}
#background #mainplanet {
width:var(--size);
height:var(--size);
background:#fff;
position:relative;
top:50%;
left:50%;
transform:translate(-50%,-50%);
border-radius:50%;
}
#background #mainplanet:before,#background #mainplanet:after{
content:"";
width:calc(var(--size) * 1.5);
height:calc(var(--size) / 2);
border:30px solid #000;
position:absolute;
top:10px;
left:-80px;
border-radius:50%;
transform: rotateX(66deg) rotateY(170deg);
}
#background #mainplanet:before{
border-top-color:transparent;
}
#background #mainplanet:after{
z-index:-3;
}
<div id="background">
<div id="mainplanet">
</div>
</div>
【问题讨论】: