圆环是由大圆嵌小圆组成的。所以,画圆环也就变成了画两个圆的事情。
我们首先需要画出第一个圆。画圆的方法有以下几种:
1、利用border-radius属性:
<div style="
width: 100px;
height: 100px;
border-radius: 50%;
background-color: #fa897b;"></div>
![](https://img.haomeiwen.com/i4632774/a0d6431ed0644bd7.png)
2、采用clip-path属性:
<div style="
width: 100px;
height: 100px;
background-color: #ccabdb;
clip-path: circle(50%);
"></div>
![](https://img.haomeiwen.com/i4632774/8a29c6322de2b49c.png)
3、使用radial-gradient属性:
<div style="
background-image: radial-gradient(circle, #456BD9, #456BD9 66%, transparent 66%);
width: 100px;
height: 100px;
"></div>
![](https://img.haomeiwen.com/i4632774/cb4d267e22ba5a32.png)
4、可以用svg的circle或path画圆:
<svg viewBox="0 0 100 100" width="100" height="100">
<circle cx="50" cy="50" r="50"/>
</svg>
以上画圆的方法有了。那么,接下来我们讲讲画两个圆的方法:
1、border + content:
<div style="
width: 100px;
height: 100px;
border-radius: 50%;
background-color: #fa897b;
border: 50px solid #ccabdb;
"></div>
![](https://img.haomeiwen.com/i4632774/b99ead5df9668a9a.png)
2、div + div:
<div style="
width: 150px;
height: 150px;
border-radius: 50%;
background-color: #fa897b;
display: flex;
align-items: center;
justify-content: center;
">
<div style="
width: 100px;
height: 100px;
border-radius: 50%;
background-color: #ccabdb;
"></div>
</div>
![](https://img.haomeiwen.com/i4632774/4155714ce6604592.png)
3、div + ::before 或 div + ::after
.circle {
width: 150px;
height: 150px;
border-radius: 50%;
background-color: #ccabdb;
display: flex;
align-items: center;
justify-content: center;
}
.circle::after {
content: '';
width: 100px;
height: 100px;
border-radius: 50%;
background-color: #fa897b;
}
<div class="circle" />
![](https://img.haomeiwen.com/i4632774/2c3c4da40f352bfa.png)
4、border-radius + radial-gradient:
<div style="
width: 100px;
height: 100px;
border-radius: 50%;
background: radial-gradient( circle closest-side,#ccabdb 50%,#fa897b 50%);
"></div>
![](https://img.haomeiwen.com/i4632774/09d2992d4db6c314.png)
5、border-radius + box-shadow:
<div style="
width: 100px;
height: 100px;
border-radius: 50%;
background: #ccabdb;
box-shadow: 0 0 0 50px #fa897b ;
"></div>
![](https://img.haomeiwen.com/i4632774/bb234f4277392edd.png)
此外,还有若干种方法,可自行根据画圆的方法以及新的css样式进行组合。
网友评论