下图是我的目标。我有 4 个 div,全部样式为圆形。我想像下图一样对齐它们。仅使用 css 的 z-index 就可以做到这一点吗?如果有人有一些见解,我一直在努力想出解决方案。你可以在小提琴中看到我的进步。
http://jsfiddle.net/v7d4s210/1/

<div id="circleContainer">
<div class="circle spin yellow"></div>
<div class="circle spin orange"></div>
<div class="circle spin red"></div>
<div class="circle spin purple"></div>
</div>
.circle {
border-radius: 50%;
display: inline-block;
margin-right: 20px;
}
#circleContainer {
width:600px;
display: block;
margin: 0 auto;
background: #f5f5f5;
position: relative;
top:200px;
}
.yellow{
width: 250px;
height: 250px;
background:red;
position: absolute;
z-index: 4;
top:-100px;
}
.orange{
width: 250px;
height: 250px;
background:blue;
position: absolute;
z-index: 3;
left:100px
}
.red{
width: 250px;
height: 250px;
background:green;
position: absolute;
z-index: 2;
left: -100px;
}
.purple{
width: 250px;
height: 250px;
background:pink;
position: absolute;
z-index: 1;
top:100px;
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
639 次 |
| 最近记录: |