Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CSS Border Radius issue [duplicate]

Tags:

css

Can anyone explain me how make a rounded border div like this image?

Screenshot

I tried but the result is not the same: the left and right side curves should be less hard.

Here it is my code snippet:

.cnt {
  margin: 0 auto;
  border: 1px solid grey;
  width: 300px;
  height: 150px;
  position: relative;
  background-color: #4a4d84;
}

.t {
  position: absolute;
  width: 100%;
  height: 50px;
  background-color: red;
  bottom: 0;
}

.t::before {
  content: "";
  position: absolute;
  width: 100%;
  height: 70px;
  top:-30px;
  background-color: red;
  border-radius: 50% 50% 0 0;
}
<div class="cnt"> 
  <div class="t">
   
  </div>
</div>

Can you help me?

like image 644
robb Avatar asked Jun 04 '26 03:06

robb


1 Answers

You want the circle to be round and much wider than the parent, yet at the same or a similar aspect ratio, hide the overflow, and you can do it with a single element.

div {
  width: 400px;
  height: 300px;
  background: blue;
  position: relative;
  overflow: hidden;
}
div:after {
  content: '';
  position: absolute;
  top: 50%; left: 50%;
  transform: translateX(-50%);
  background: red;
  height: 300%; width: 400%;
  border-radius: 50%;
}
<div></div>
like image 102
Michael Coker Avatar answered Jun 08 '26 01:06

Michael Coker



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!