Heim  >  Fragen und Antworten  >  Hauptteil

Untere Kante des Div mit CSS nach innen krümmen

Ich möchte die Unterkante dieses rechteckigen Divs/Hintergrunds mit CSS biegen, sodass das Ergebnis so aussieht:

Weiß jemand, wie man es umsetzt?


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


P粉384366923P粉384366923332 Tage vor777

Antworte allen(2)Ich werde antworten

  • P粉211600174

    P粉2116001742023-10-24 15:57:52

    检查一下。我用 :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;
    }

    Antwort
    0
  • P粉980815259

    P粉9808152592023-10-24 00:00:31

    只需使用 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;
    }

    Antwort
    0
  • StornierenAntwort