Search code examples
cssoutline

How to make CSS outline cornered?


I have code that provides me that

enter image description here

CSS Code:

  .about-best-big-vector-right {
  width: 1380px;
  float: right;
  border-top: 140px solid #272838;
  border-left: 75px solid transparent;
  position: relative;
  outline: 3px solid #eda225;
  outline-offset: .3rem;
  -moz-outline-radius-bottomleft: 2em;
}

HTML Code: <div class="about-best-big-vector-right"></div>

But I want to achive that and can't make cornered bottom-left? enter image description here


Solution

  • Don't use border for this, use skew transformation:

    .box {
      overflow: hidden;
      width: 40%;
      margin-left: auto;
    }
    
    .box::before {
      content: "";
      display: block;
      margin-right: -10px;
      height: 150px;
      background: #000 content-box;
      padding: 5px;
      border: 4px solid orange;
      transform-origin: top;
      transform: skewX(30deg);
    }
    <div class="box">
    
    </div>