Home  >  Q&A  >  body text

Curl bottom of div to inside using CSS

<p>I want to bend the bottom edge of this rectangular div/background using CSS, so the result is like this: </p> <p> Does anyone know how to implement it? </p> <p> <pre class="brush:css;toolbar:false;">.curved { margin: 0 auto; height: 400px; background: lightblue; border-radius:0 0 200px 200px; }</pre> <pre class="brush:html;toolbar:false;"><div class="container"> <div class="curved"></div> </div></pre> </p>
P粉617237727P粉617237727444 days ago468

reply all(2)I'll reply

  • P粉936568533

    P粉9365685332023-08-25 15:27:24

    check. I created this using :after pseudo-element. It helps if the background is a solid color.

    .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;
    }
    <div class="container">
      <div class="curved"></div>
    </div>

    reply
    0
  • P粉564301782

    P粉5643017822023-08-25 10:20:51

    Just use border-radius and rely on some overflow. You can also consider pseudo-elements to avoid extra markup:

    .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;
    }
    <div class="container">
    </div>

    reply
    0
  • Cancelreply