如何为文本创建自定义边框

How to create customized border to text

如何得到如下图的边框。

众所周知,我已经为文本尝试了 border-bottom。但是无法像这样了解边界。我会尝试使用伪元素吗?

h1 {
  display:inline-block;
  position:relative;
  padding-bottom:4px;
}
h1:before {
  display:block;
  content:"";
  width:70%;
  height:1px;
  background:orange;
  position:absolute;
  left:50%;
  bottom:0;
  transform:translate(-50%);
}
h1:after {
  display:block;
  content:"";
  width:20%;
  height:4px;
  background:orange;
  position:absolute;
  left:50%;
  bottom:-4px;
  transform:translate(-50%);
}
<h1>
Vijay Kumar
</h1>

您可以使用 :before:after 伪元素在元素底部创建两行并使用 position: absolute.

定位它们

h1 {
  position: relative;
  display: inline-block;
  margin: 25px;
}
h1:after,
h1:before {
  content: '';
  position: absolute;
  bottom: -2px;
  height: 1px;
  width: 60%;
  left: 0;
  background: #C0932E;
  transform: translateY(100%);
}
h1:after {
  height: 3px;
  width: 30%;
}
.center:before,
.center:after {
  left: 50%;
  transform: translate(-50%, 100%);
}
.start:before {
  width: 100%;
}
<h1 class="start">LOREM IPSUM</h1><br>
<h1 class="center">Lorem ipsum dolor.</h1>

试试这个:

h1 {
    border-bottom: 2px solid orange;
    width: 200px;
    text-align: center;
    position: relative;
}

h1:after{
    content: '';
    position: absolute;
    width: 100px;
    border-bottom: 3px solid orange;
    top: 39px;
    left: 50px;
}
<h1>This is Test</h1>