skip to Main Content

I want to create this shape using CSS but cannot get the top right corner to work.
enter image description here

this is all the code that I have.

ul.rounded-tabs li {
display: inline-block;
background: #ccc;
margin: 0 40px;
padding: 0.625rem 2rem;
position: relative;
border-bottom-left-radius: 25px;
border-bottom-right-radius: 25px;
cursor: pointer;
}

ul.rounded-tabs li:after {
content: '';
height: 20px;
width: 20px;
background: #ccc;
position: absolute;
top: 0;
right: -20px;
z-index: 1;
}

ul.rounded-tabs li span:after {
content: '';
height: 40px;
width: 40px;
background:transparent;
position: absolute;
top: 0;
right: -40px;
z-index: 2;
border-radius: 50%;
}

2

Answers


  1. You need to use css :after Pseudo-element with box-shadow.

    ul.rounded-tabs li {
      display: inline-block;
      position: relative;
      margin: 0 40px;
      padding: 0.625rem 2rem;
      background: #ccc;
      border-radius: 25px 0 25px 25px;
      cursor: pointer;
    }
    
    ul.rounded-tabs li:after {
      content: '';
      height: 20px;
      width: 20px;
      background: transparent;
      position: absolute;
      top: 0;
      right: -20px;
      border-radius: 10px 0 10px 0;
      box-shadow: -10px 0 0 0 #ccc;
    }
    <ul class="rounded-tabs">
      <li>List 1</li>
      <li>List 2</li>
    </ul>
    Login or Signup to reply.
  2. You can also do this with clip-path and a path() shape instead, which I find a little more straight forward than border and shadow tricks (although YMMV as paths don’t reliably support percentage measurements and calc so this may be less flexible). Here’s a rough example:

    body {
      background: purple;
    }
    
    ul {
      margin: 0;
      padding: 0;
      display: flex; /* or display: grid */
    }
    
    li {
      display: block;
      position: relative;
      text-transform: uppercase;
      font-family: "Arial Rounded MT Bold";
      color: lightgreen;
      background: black;
      padding: 8px 16px;
      margin: 0 8px;
      border-radius: 18px;
    }
    
    li::after {
      content: '';
      position: absolute;
      top: 0;
      left: calc(100% - 16px);
      height: 18px;
      width: 24px;
      background: black;
      clip-path: path("M 0,0 L 24,0 C 24,0 16,0 16,18 Z");
    }
    <ul>
      <li>One</li>
      <li>Two</li>
      <li>Three</li>
    </ul>
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search