css怎么制作圆圈
使用 border-radius 属性制作圆圈
通过将元素的 border-radius 设置为 50%,可以将方形元素变为圆形。需确保元素的宽度和高度相等。

.circle {
width: 100px;
height: 100px;
border-radius: 50%;
background-color: #3498db;
}
使用 SVG 绘制圆圈
SVG 的 <circle> 标签可直接绘制圆形,适合需要动态或复杂图形的场景。

<svg width="100" height="100">
<circle cx="50" cy="50" r="40" fill="#e74c3c" />
</svg>
使用伪元素创建圆圈
通过 ::before 或 ::after 伪元素生成圆形,常用于装饰性元素。
.element::before {
content: "";
display: inline-block;
width: 20px;
height: 20px;
border-radius: 50%;
background-color: #2ecc71;
}
使用 clip-path 裁剪圆形
clip-path 的 circle() 函数可精确裁剪出圆形区域,支持复杂形状控制。
.clip-circle {
width: 120px;
height: 120px;
background-color: #9b59b6;
clip-path: circle(50% at 50% 50%);
}





