有必要不断地制作HTML
这样CSS
的圆圈。有一个代码已经完成,但是使用它是不可能在选定的一个上画一个圆圈并做出正确的阴影。
section {
width: 12em;
margin: auto;
}
.chart {
position: relative;
overflow: hidden;
/* .triangle выходят за пределы */
}
.center {
position: absolute;
width: 120px;
height: 120px;
border-radius: 50%;
left: 36px;
top: 36px;
background-color: #FFF;
z-index: 2;
}
.chart:before {
content: "";
display: block;
padding-top: 100%;
}
.triangle {
position: absolute;
left: 0;
top: 0;
right: 0;
bottom: 50%;
transform-origin: center bottom;
overflow: hidden;
}
.circle {
height: 100%;
width: 100%;
background: silver;
border-radius: 50% 50% 0 0 / 100% 100% 0 0;
transform-origin: center bottom;
transform: rotate(156.5deg);
}
<section class="chart">
<div class="center"></div>
<div class="triangle" style="transform:rotate( 0deg)">
<div class="circle" style="background:#BD0204"></div>
</div>
<div class="triangle" style="transform:rotate( 22.5deg)">
<div class="circle" style="background:#BD0204"></div>
</div>
<div class="triangle" style="transform:rotate(45deg)">
<div class="circle" style="background:#FA3F3C"></div>
</div>
<div class="triangle" style="transform:rotate(67.5deg)">
<div class="circle" style="background:#FFFC3E"></div>
</div>
<div class="triangle" style="transform:rotate(90deg)">
<div class="circle" style="background:#BCBE00"></div>
</div>
<div class="triangle" style="transform:rotate(112.5deg)">
<div class="circle" style="background:#02C103"></div>
</div>
<div class="triangle" style="transform:rotate(135deg)">
<div class="circle" style="background:#44FA42"></div>
</div>
<div class="triangle" style="transform:rotate(157.5deg)">
<div class="circle" style="background:#3AFEFF"></div>
</div>
<div class="triangle" style="transform:rotate(180deg)">
<div class="circle" style="background:#02BCBD"></div>
</div>
<div class="triangle" style="transform:rotate(202.5deg)">
<div class="circle" style="background:#0301BF"></div>
</div>
<div class="triangle" style="transform:rotate(225deg)">
<div class="circle" style="background:#3D3FF9"></div>
</div>
<div class="triangle" style="transform:rotate(247.5deg)">
<div class="circle" style="background:#FE40FD"></div>
</div>
<div class="triangle" style="transform:rotate(270deg)">
<div class="circle" style="background:#BC02C0;"></div>
</div>
<div class="triangle" style="transform:rotate(292.5deg)">
<div class="circle" style="background:#FFF"></div>
</div>
<div class="triangle" style="transform:rotate(315deg)">
<div class="circle" style="background:#BDBCBF"></div>
</div>
<div class="triangle" style="transform:rotate(337.5deg)">
<div class="circle" style="background:#3F3F3F"></div>
</div>
<div class="triangle" style="transform:rotate(360deg); z-index: 2">
<div class="circle" style="background:#020202"></div>
</div>
</section>
我不知道这个设计有多重要……我用一个切口代替了箭头——它看起来并没有太大的不同,但代码大小却大大减少了。
仅限 HTML 和 CSS(CSS 变量、圆锥和径向渐变、drop-shadow()):