Search code examples
htmlcssoutline

Round the corners of outline property CSS


I have this element with this style added:

.checkout-step.current .number {
  background-color: #d26d51;
  outline: 1px solid #d26d51;
  outline-offset: 4px;
}

enter image description here

But I not want square corners in the outline, I want round the corners, like this example: enter image description here

How can I do this?


Solution

  • My approach is as follows. Please check JSFiddle. I have added following HTML.

    <a href="#">2</a>
    

    I have added following css.

    a {
      background: #999;
      width: 40px;
      height: 40px;
      border-radius: 20px;
      text-decoration: none;
      color: #fff;
      display: inline-block;
      line-height: 40px;
      position: relative;
      border: 2px solid #000;
      text-align: center;
    }
    a:after {
      content: '';
      display: block;
      position: absolute;
      top: -10px;
      bottom: -10px;
      left: -10px;
      right: -10px;
      border-radius: 30px;
      border: 2px solid #f00;
    }