如何在 div 上创建不均匀的圆边?

How to create uneven rounded sides on a div?

我一直在尝试制作一个 DIV 不均匀的圆边,如下所示:

我检查了一些解决方案,我能找到的最接近的解决方案是使用 border-radius。我用过:

border-bottom-left-radius: 80%50px;
border-bottom-right-radius: 30%30px; 

这就是我得到的:

如何做到这一点?

可以考虑clip-path

.box {
  height: 200px;
  width: 200px;
  background: blue;
  clip-path: circle(75% at 65% 10%);
}
<div class="box">

</div>

或使用radial-gradient

.box {
  height: 200px;
  width: 200px;
  background: radial-gradient(circle at 65% 10%, blue 75%,#0000 75.5%);

}
<div class="box">

</div>

或者使用带有border-radius的伪元素并依赖overflow

.box {
  height: 200px;
  width: 200px;
  position: relative;
  overflow: hidden;
}

.box:before {
  content: "";
  position: absolute;
  inset: 0 -10% 10%;
  background: blue;
  border-radius: 0 0 50% 100%;
}
<div class="box">

</div>

别忘了 SVG 解决方案(作为常规元素或背景)

svg {
 display:inline-block;
}

.box {
  display:inline-block;
  height:200px;
  width:200px;
  background:url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 64 64'  width='200' height='200' fill='blue'> <path d='M0 0 L0 28 C10 46 30 60 64 48 L64 0 Z' /></svg>")0 0/100% 100% no-repeat;
}
<svg
  xmlns='http://www.w3.org/2000/svg'
  viewBox='0 0 64 64'
  width='200' height='200'
  fill='blue'>
  <path d='M0 0 L0 28 C10 46 30 60 64 48 L64 0 Z' />
</svg>

<div class="box">
</div>

这是一个很好的在线工具,可以轻松调整 SVG http://jxnblk.com/paths/?d=M0 0 L0 28 C10 46 30 60 64 48 L64 0 Z


你也可以考虑mask-image:

.box {
  height: 200px;
  width: 200px;
  background:blue;
  -webkit-mask-image: radial-gradient(circle at 65% 10%, #fff 75%,#0000 75.5%);
          mask-image: radial-gradient(circle at 65% 10%, #fff 75%,#0000 75.5%);

}
<div class="box">

</div>

这是 radial-gradient 解决方案的另一种语法,不使用 at,其中

.box {
  height: 200px;
  width: 200px;
  background: 
    radial-gradient(blue 60.5%,#0000 61%) 35% 100%/200% 200% no-repeat;
}
<div class="box">

</div>