用css伪类实现文字左右两边有横线的效果

<!doctype html>
<html>
<head>
    <meta charset="UTF-8">
    <meta name="Generator" content="EditPlus®">
    <meta name="Author" content="">
    <meta name="Keywords" content="">
    <meta name="Description" content="">
    <title>Document</title>
    <style>
        .title{
            width:200px;
            height:50px;
            line-height:50px;
            text-align:center;
            position:relative;
        }
        .title::after, .title::before{
            position: absolute;
            width:30px;
            height:3px;
            background:#000;
            content:'';
            top:25px;
        }

        .title::after{
            left:0;
        }
        .title::before{
            right:0;
        }

    </style>
</head>
<body>
<div class="title">
    这里标题内容
</div>
</body>
</html>

猜你喜欢

转载自blog.csdn.net/sunjynyue/article/details/83013614