是否可以仅在矩形的一侧绘制三重边框?

Is it Possible to Draw a Triple Border only on one side of a Rectangle?

我想在不使用额外的情况下仅在矩形的一侧设置三重边框 Html tag.The 到目前为止我尝试过的代码如下所示。

方法#1

#element {
  width: 100px;
  height: 100px;
  box-shadow: 0 0 0 3px #000, 0 0 0 6px #f00, 0 0 0 9px #000;
}
<div id="element"></div>

方法#2

#element {
  width: 100px;
  height: 100px;
  border: 3px solid black; /* inner border */
  box-shadow: 0px 0px 0px 15px black; /* outer 'border' */
  outline: 12px solid green; /* fill */
  margin-left: 30px;
  margin-top: 30px;
}
<div id="element"></div>

但这只能用于万一你需要所有边上的三重边框,而不是我只需要一个三重边框 side.Is 可能吗?请帮助我

使用这个 CSS 属性

box-shadow: 5px 0px 0 0px #000, 10px 0px 0 0px #f00, 15px 0px 0px 0px #000;

#element {
  width: 100px;
  height: 100px;
  box-shadow: 5px 0px 0 0px #000, 10px 0px 0 0px #f00, 15px 0px 0px 0px #000;
}
<div id="element"></div>

您可以使用 beforeafter 来实现。

#element {
  width: 100px;
  height: 100px;
  border-right: 5px solid black; /* inner border */
  /* box-shadow: 0px 0px 0px 15px black; */ /* outer 'border' */
  /* outline: 12px solid green; */ /* fill */
  margin-left: 30px;
  margin-top: 30px;
}
.triple-right {
  position: relative;
}
.triple-right:before, .triple-right:after {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  width: 5px;
}
.triple-right:before {
  background-color: green;
  right: -10px;
}
.triple-right:after {
  background-color: black;
  right: -15px;
}
<div id="element" class="triple-right"></div>

这是另一个使用渐变的想法:

#element {
  width: 100px;
  height: 100px;
  background:
    linear-gradient(#000,#000) right/ 5px 100%,
    linear-gradient(red,red)   right/ 10px 100%,
    linear-gradient(blue,blue) right/ 15px 100%;
    /*And so on if you want more border*/
    
 background-repeat:no-repeat;
  
}
<div id="element"></div>