Search code examples
htmlcsssvgcss-shapes

Rectangle with rounded sides


How can I code these rectangles with rounded corenrs using CSS/SVG/etc. pictures :

enter image description here

I tried coding this with border-radius, but with border-radius horizontal or vertical sides are straight.

And how I can code lower ridge of rounded rectangles?


Solution

  • Use svg's bezier curves.

    enter image description here

    .container {
      position: relative;
      width: 400px;
      margin: 0 auto;
    }
    .shape {
      position: absolute;
      z-index: -1;
    }
    .content {
      position: relative;
      width: 400px;
      padding: 4em 3em;
      box-sizing: border-box;
      color: #FFEFE3;
      font-size: 13.1px;
    }
    <div class="container">
      <svg class="shape" width="400" height="100%" viewBox="-1 -1 401 158" preserveAspectRatio="none">
        <path fill="#FFAC61" d="M0 75 c1 -30 4 -60 30 -65 q200 -20 343 0 c20 6 24 40 25 65 c0 25 -6 57 -27 65 c-90 17 -210 6 -240 7 c-10 -1 -20 0 -40 8 c-7 0 -10 -1 -15 -8 c-4 -4 -20 -6 -50 -7 c-30 -10 -23 -57 -27.5 -73" />
      </svg>
      <div class="content">The English Wikipedia is the English-language edition of the free online encyclopedia Wikipedia.</div>
    </div>