Search code examples
htmlcsscss-shapes

Rounded corner with pointy edge on button CSS


I am thinking of using pseudo elements before and after in button to achieve this rounded-sides-triangle (rotated) and pointy corner. See photo for desired result.


Solution

  • You can try something like this:

    .box {
      width: 300px;
      height: 80px;
      --c: #000;
      position: relative;
      line-height: 80px;
      font-size: 20px;
      text-align: center;
      color: #fff;
      z-index: 0;
    }
    
    .box:before,
    .box:after {
      content: "";
      position: absolute;
      background:linear-gradient(#000,#000) top/100% 50% no-repeat;
      top: 0;
      bottom: 0;
      left: 0;
      right: 0;
      z-index: -1;
    }
    
    .box:before {
      border-radius: 60px 60px 0 0;
    }
    
    .box:after {
      border-radius: 0 0 60px 60px;
      background-position:bottom;
    }
    <div class="box">
      Some text
    </div>