欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

CSS:画锯齿形边的圆

程序员文章站 2022-07-01 20:29:33
...

锯齿形边的圆可以由十二个正三角形构成。
CSS:画锯齿形边的圆

.circle {
  width: 80vh;
  height: 80vh;
  position: relative;
  background-color: #CCCCCC;
}

.triangle {
  position: absolute;
  left: 6.7%;
  top: 0;
  width: 86.6%;
  height: 75%;
  background-color: plum;
  clip-path: polygon(50% 0, 0 100%, 100% 100%);
  transform-origin: center 66.6%;
}

.triangle:nth-child(2) {
  transform: rotate(10deg);
}

.triangle:nth-child(3) {
  transform: rotate(20deg);
}

.triangle:nth-child(4) {
  transform: rotate(30deg);
}

.triangle:nth-child(5) {
  transform: rotate(40deg);
}

.triangle:nth-child(6) {
  transform: rotate(50deg);
}

.triangle:nth-child(7) {
  transform: rotate(60deg);
}

.triangle:nth-child(8) {
  transform: rotate(70deg);
}

.triangle:nth-child(9) {
  transform: rotate(80deg);
}

.triangle:nth-child(10) {
  transform: rotate(90deg);
}

.triangle:nth-child(11) {
  transform: rotate(100deg);
}

.triangle:nth-child(12) {
  transform: rotate(110deg);
}
<div class="circle">
  <div class="triangle"></div>
  <div class="triangle"></div>
  <div class="triangle"></div>
  <div class="triangle"></div>
  <div class="triangle"></div>
  <div class="triangle"></div>
  <div class="triangle"></div>
  <div class="triangle"></div>
  <div class="triangle"></div>
  <div class="triangle"></div>
  <div class="triangle"></div>
  <div class="triangle"></div>
</div>

效果图:
CSS:画锯齿形边的圆