Css - Need 'triple' border

前端 未结 1 1592
说谎
说谎 2021-01-23 06:47

I have this css:

border: 2px solid #00ff60;
outline: 1px solid #000;
outline-offset: 0px;

Which produces this:

How can I adju

1条回答
  •  说谎
    说谎 (楼主)
    2021-01-23 07:35

    Consider using box-shadow. You can also do it with multiple box-shadow :

    .box {
      border: 5px solid #00ff60;
      outline: 5px solid #000;
      outline-offset: 0px;
      height: 100px;
      width: 100px;
      box-shadow:0px 0px 0px 5px #000 inset;
      display:inline-block;
    }
    
    .box-alt {
      border: 5px solid #000;
      outline: 5px solid #00ff60;
      outline-offset: 0px;
      height: 100px;
      width: 100px;
      box-shadow:0px 0px 0px 10px #000;
      margin:10px 20px;
      display:inline-block;
    }
    
    .box-alt-2 {
      height: 100px;
      width: 100px;
      box-shadow:0px 0px 0px 5px #000,
      0px 0px 0px 10px #00ff60,
      0px 0px 0px 15px #000;
      margin:10px 20px;
      display:inline-block;
    }

    You can also achieve the same using multiple background and linear-gradient:

    .box {
      height: 100px;
      width: 100px;
      background:
       linear-gradient(#fff,#fff) center/calc(100% - 20px) calc(100% - 20px),
       linear-gradient(red,red) center/calc(100% - 15px) calc(100% - 15px),
       linear-gradient(#000,#000) center/calc(100% - 10px) calc(100% - 10px),
       linear-gradient(green,green) center/calc(100% - 5px) calc(100% - 5px),
       linear-gradient(#000,#000) center/100% 100%; 
      background-repeat:no-repeat;
    }

    0 讨论(0)
提交回复
热议问题