答案 0 :(得分:0)
我希望这会有所帮助,
.heading{
display: block;
width: 100%;
position: relative;
text-align: center;
padding: 50px 0px;
}
.heading h2{
font-size: 25px;
color: #000;
text-align: center;
display: inline-block;
background-color: #fff;
width: 40%;
margin: auto;
}
.heading:before {
content: '';
position: absolute;
width: 100%;
height: 2px;
left: 0;
background: #000;
top: 50%;
z-index: -1;
}
<div class="heading">
<h2>Function</h2>
</div>
答案 1 :(得分:0)
.wrapper{
position: relative;
text-align: center;
padding: 50px 0px;
}
.wrapper h2{
font-size: 24px;
color: #000;
text-align: center;
display: inline-block;
background-color: #fff;
padding: 0 30px;
margin: auto;
}
.wrapper:before {
content: '';
position: absolute;
width: 100%;
height: 2px;
left: 0;
background: #999;
top: 50%;
margin-top: -1px; /*this will keep this line vertically center to heading text*/
z-index: -1;
}
<div class="wrapper">
<h2>Functions</h2>
</div>