How to create a border that fully covers the adjacent corners in CSS?

前端 未结 7 1937
闹比i
闹比i 2020-12-17 09:00

I have a div with a 1px border and I\'m trying to create a 3px border in another color to that div. I\'m using this code:

box {
  border: 1px solid #ffffd;
  b         


        
7条回答
  •  不知归路
    2020-12-17 09:11

    Use css :after pseudo-class, docs

    .box_big {
      border: 10px solid #ffffd;
      position:relative;
      z-index: 1;
    }
    .box_big:after{
        height: 10px;
        position: absolute;
        top:-10px; left:-10px; right:-10px;
        content: " ";
        z-index: 2;
        background: red;
    }
    .box {
      border: 1px solid #ffffd;
      position:relative;
      z-index: 1;
    }
    .box:after{
        height: 3px;
        position: absolute;
        top:-3px; left:-1px; right:-1px;
        content: " ";
        z-index: 2;
        background: red;
    }
    big box

    your box

提交回复
热议问题