在CSS中创建圆角底角

时间:2022-12-14 02:41:33

I am trying to make a CSS shape with a rounded bottom corner with border-radius, but failing to understand how to:

我正在尝试使用带有border-radius的圆角底角制作CSS形状,但无法理解如何:

.rounded-css {
  border-radius: 5px;
  display: block;
  background: #669999;
  width: 150px;
  height: 200px;
}
<div class="rounded-css"></div>

Expected output:

在CSS中创建圆角底角

2 个解决方案

#1


5  

You can use border-radius: 0 0 50% 50%; to make the whole bottom part round. With adding a white pseudo element ::after, you can "cut" the unwanted upper part to only show the curve:

你可以使用border-radius:0 0 50%50%;使整个底部圆形。通过添加白色伪元素:: after,您可以“剪切”不需要的上部以仅显示曲线:

.rounded {
  border-radius: 0 0 50% 50%;
  display: block;
  background: #669999;
  width: 100%;
  height: 70px;
  margin-top: -35px;
}
.rounded::after {
  content: "";
  display: block;
  width: inherit;
  height: 35px;
  background: white;
}
<div class="rounded"></div>

#2


4  

I think you can adapt this to the container you want to put this in. I think it's pretty much what you are looking for.

我想你可以根据你想要的容器来调整它。我认为它几乎就是你要找的东西。

.rounded-css {
  border-radius: 100%;
  display: block;
  background: black;
  border-bottom: 40px #669999 solid;
  border-top: 40px transparent solid;
  position: relative;
  top: -60px;
  overflow: hidden;
}
<div class="rounded-css"></div>

#1


5  

You can use border-radius: 0 0 50% 50%; to make the whole bottom part round. With adding a white pseudo element ::after, you can "cut" the unwanted upper part to only show the curve:

你可以使用border-radius:0 0 50%50%;使整个底部圆形。通过添加白色伪元素:: after,您可以“剪切”不需要的上部以仅显示曲线:

.rounded {
  border-radius: 0 0 50% 50%;
  display: block;
  background: #669999;
  width: 100%;
  height: 70px;
  margin-top: -35px;
}
.rounded::after {
  content: "";
  display: block;
  width: inherit;
  height: 35px;
  background: white;
}
<div class="rounded"></div>

#2


4  

I think you can adapt this to the container you want to put this in. I think it's pretty much what you are looking for.

我想你可以根据你想要的容器来调整它。我认为它几乎就是你要找的东西。

.rounded-css {
  border-radius: 100%;
  display: block;
  background: black;
  border-bottom: 40px #669999 solid;
  border-top: 40px transparent solid;
  position: relative;
  top: -60px;
  overflow: hidden;
}
<div class="rounded-css"></div>