12

I've been trying to make a DIV with uneven rounded sides like this:

enter image description here

I've checked some solutions and the closest I can get to it is by using border-radius. I've used:

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

And this is what I've got: enter image description here

How can this be done?

Temani Afif
  • 245,468
  • 26
  • 309
  • 415
A. Diaz
  • 167
  • 1
  • 2
  • 9

1 Answers1

26

You can consider clip-path

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

</div>

Or use radial-gradient

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

}
<div class="box">

</div>

Or use a pseudo element with border-radius and rely on 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>

And let's don't forget the SVG solution (as a regular element or background)

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>

Here is a good online tool to easily adjust the SVG http://jxnblk.com/paths/?d=M0 0 L0 28 C10 46 30 60 64 48 L64 0 Z


You can also consider 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>

Here is another syntax for the radial-gradient solution without the use of at which is not supported in Safari

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

</div>
Temani Afif
  • 245,468
  • 26
  • 309
  • 415
  • None of the above solution works in my case. I need left border curve not bottom. I need all browser supported solution – Sagar Kodte Mar 31 '20 at 14:26
  • @SagarKodte you need *to adjust* the code to have your left border. Don't expect to get a ready-to-copy-past code. This answer gives you all the possible ways – Temani Afif Mar 31 '20 at 14:27
  • I tried your pseudo element css solution but it's not getting as per design even changing the border-radius property and other solutions are not supported by some browsers like edge and safari – Sagar Kodte Mar 31 '20 at 14:30
  • Even there are some other points in my question which is not related to this question. – Sagar Kodte Mar 31 '20 at 14:37
  • This one of the most informative answers I have ever seen , thank you. – Ahmed Abdelfattah Mar 23 '21 at 23:40