答案 0 :(得分:3)
您可以使用: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>
&#13;
答案 1 :(得分:1)
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>
答案 2 :(得分:0)
试试这个:
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>