html代码
<h2 class="top-title">庆祝中华人民共和国成立七十周年</h2>
css代码
.top-title{
line-height: 188px;
width: 1000px;
margin: 0 auto;
text-align: center;
color: #fdefab;
font-size: 20px;
position: relative;
}
.top-title::before,.top-title::after{
content:'';
position: absolute;
top: 50%;
background: #fdefab;
height: 1px;
width: 15%; /*相当于父元素宽度的百分之15,150px*/
}
.top-title::before {
left: 8%; /*调整背景横线的左右距离*/
}
.top-title::after {
right: 8%;
}