Incomplete borders around div

后端 未结 5 1552
日久生厌
日久生厌 2021-02-12 09:09

I am looking for a way to create an incomplete square with borders with some text and a background with pure css. Here is what I am trying to achieve:

<

5条回答
  •  一整个雨季
    2021-02-12 09:44

    You can do with css pseudo ::after and ::before , something like this

    .incomplete-box{
      border: solid 1px #fff;
      border-right: none;
      width: 100px;
      height: auto;
      position: relative;
    }
    .incomplete-box::after,
    .incomplete-box::before{
      content: '';
      position: absolute;
      height: 30%;
      width: 1px;
      background-color: #fff;
      right: 0;
    }
    .incomplete-box::after{
      top: 0;
    }
    .incomplete-box::before{
      bottom: 0;
    }
    

    Demo

    Fixed width and height : https://jsfiddle.net/nikhilvkd/qt5ne3yw/

    Auto width and height: https://jsfiddle.net/nikhilvkd/0v3k8rv8/2/

提交回复
热议问题