注:宽度默认跟随父元素宽度
DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Documenttitle>
<style>
.box {
display: flex;
align-items: center;
justify-content: center;
justify-items: center;
white-space: nowrap;
}
.box::before {
background: linear-gradient(90deg, transparent 0%, #e6e6e6 10%);
}
.box::before,
.box::after {
content: '';
display: block;
width: 50%;
height: 1px;
flex-grow: 1;
flex-shrink: 1;
}
.box::after {
background: linear-gradient(270deg, transparent 0%, #e6e6e6 10%);
}
.info {
color: #999999;
padding: 0 0.5em;
}
style>
head>
<body>
<div class="box">
<span class="info">我是有底线的span>
div>
body>
html>
效果图: