【发布时间】:2021-02-26 18:34:11
【问题描述】:
我正在尝试练习制作如上图。任何人都可以帮助我,如何克服这种类型的重叠,我认为z-index 将解决这种类型的问题,但我不明白如何?
但是直到现在我都能做出这个数字……
这是我的代码:
* {
margin: 0;
background:#222730;
}
.a{
max-width:100%;
height:150px;
margin-top:4.69em;
background:#4CAAB3;
}
.b{
width:250px;
height:250px;
margin-top:-12.5em;
transform: rotate(45deg);
margin-left:auto;
margin-right:auto;
background:#222730;
}
.c{
width:150px;
height:150px;
margin-top:-12.5em;
transform: rotate(45deg);
margin-left:auto;
margin-right:auto;
background:#4CAAB3;
}
.d{
background:white;
margin-left:auto;
margin-right:auto;
width:50px;
height:50px;
z-index:;
margin-top:-8em;
}
<div class="sq">
<div class="a "></div>
<div class="b"></div>
<div class="c"></div>
<div class="d "></div>
</div>
【问题讨论】:
-
要让
z-index工作,该职位不得为static。