How does this effect of the border come true?

the effect is as follows

Css
Apr.14,2022

reference:

  1. https://codepen.io/AZGSKULL/p...
  2. https://codepen.io/hari_shanx...

A handful of codepen.


this is more expensive to write in CSS, so you can design and give you a picture instead.


for example, you define four span, then use positioning, and then set their borders to display


css
 .rect {
      position: absolute;
      top: 20px;
      left: 20px;
      width: 100px;
      height: 100px;
      text-align: center;
      line-height: 100px;
      background: linear-gradient(to left, -sharpf00, -sharpf00) left top no-repeat,
        linear-gradient(to bottom, -sharpf00, -sharpf00) left top no-repeat,
        linear-gradient(to left, -sharpf00, -sharpf00) right top no-repeat,
        linear-gradient(to bottom, -sharpf00, -sharpf00) right top no-repeat,
        linear-gradient(to left, -sharpf00, -sharpf00) left bottom no-repeat,
        linear-gradient(to bottom, -sharpf00, -sharpf00) left bottom no-repeat,
        linear-gradient(to left, -sharpf00, -sharpf00) right bottom no-repeat,
        linear-gradient(to left, -sharpf00, -sharpf00) right bottom no-repeat;
      background-size: 1px 20px, 20px 1px, 1px 20px, 20px 1px;
    }
    
html
  <div class="rect"></div>
.
Menu