我怎样用CSS::after和::before来画这个形状?

ifsvaxew  于 2023-01-18  发布在  其他
关注(0)|答案(2)|浏览(141)

我知道有很多不同的方式来绘制CSS,但我想画这个形状使用CSS::before和::after伪元素。

只有黄色的部分我画不出来。

.body{
    width:100%;
    height:100%;
    background:#191919;
    display: flex;
    justify-content: center;
    align-items: center;
  }
.circle {
    position: relative;
    width: 160px;
    height: 160px;
    background: #824B20;
    border-radius: 50%;
  }
.circle::before{
    content: "";
    width: 100px;
    height: 100px;
    background: #E08027;
    position: absolute;
    border-radius: 50%;
    top: 50%;
    left: 50%;       
    transform: translate(-50%,-50%);
  }
.circle::after{
    content:"";
   /*color : #FFF58F */    
  }
<div class="body"><div class="circle";div><div><div>
cwtwac6a

cwtwac6a1#

仅使用渐变的想法:

.box {
  width: 200px;
  aspect-ratio:1;
  border-radius: 50%;
  background:
    radial-gradient(circle at 78% 50%, yellow 4%,#0000 4.5%),
    radial-gradient(circle at 22% 50%, yellow 4%,#0000 4.5%),
    radial-gradient(at top,#0000 33%,yellow 34% 45%,#0000 46%) 
      bottom/100% 50% no-repeat,
    radial-gradient(#E08027 40%,#824B20 41%);
}
<div class="box"></div>
ztmd8pv5

ztmd8pv52#

.body {
  width: 100%;
  height: 100vh;
  background: #191919;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
}

.circle {
  box-sizing: border-box;
  position: relative;
  width: 160px;
  height: 160px;
  background: #E08027;
  border: 30px solid #824B20;
  border-radius: 50%;
}

.half-circle {
  position: absolute;
  width: 85px;
  height: 85px;
  border: 14px solid #FFF58F;
  border-top-color: transparent;
  border-left-color: transparent;
  border-radius: 50%;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) rotate(45deg);
}

.half-circle::before,
.half-circle::after {
  content: "";
  position: absolute;
  top: 69px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #FFF58F;
}

.half-circle::before {
  left: 0;
}

.half-circle::after {
  left: 71px;
  transform: translate(-2px, -70px);
}
<div class="body">
  <div class="circle">
    <div class="half-circle"></div>
  </div>
</div>

相关问题