使用CSS将div的底部边缘向内弯曲
P粉384366923
P粉384366923 2023-10-23 19:55:32
0
2
769

我想用CSS弯曲这个矩形div/背景的底边,所以结果是这样的:

有人知道如何实现它吗?


.curved {
  margin: 0 auto;
  height: 400px;
  background: lightblue;
  border-radius:0 0 200px 200px;
}
<div class="container">
  <div class="curved"></div>
</div>


P粉384366923
P粉384366923

全部回复(2)
P粉211600174

检查一下。我用 :after 伪元素创建了这个。如果背景是纯色的话会很有帮助。

.curved {
  margin: 0 auto;
  width: 300px;
  height: 300px;
  background: lightblue;
  position: relative;
}
.curved:after{
  background: white;
  position: absolute;
  content: "";
  left:0;
  right:0;
  bottom: -25px;
  height: 50px;
  border-radius: 50% 50% 0 0;
}
P粉980815259

只需使用 border-radius 并依赖一些溢出。您还可以考虑伪元素以避免额外的标记:

.container {
  margin: 0 auto;
  width: 500px;
  height: 200px;
  background: lightblue;
  position: relative;
  overflow: hidden;
}

.container:after {
  content: "";
  position: absolute;
  height: 80px;
  left: -10%;
  right: -10%;
  border-radius: 50%;
  bottom: -25px;
  background: #fff;
}
热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板
关于我们 免责声明 Sitemap
PHP中文网:公益在线PHP培训,帮助PHP学习者快速成长!