首页 > 代码库 > 文字两边的横线实现

文字两边的横线实现

技术分享

横线用到了伪类进行实现。

css:

h4,h5 {
    text-align: center;
}
h5{
    color: gray;
}
.onimg_title:before{

    display: inline-block;

    position: relative;

    top:-7px;

    right: 20px;

    content: "";

    width: 100px;

    height: 0px;

    border: 1px solid black;

}
.onimg_title:after{

    display: inline-block;

    position: relative;

    top:-7px;

    left: 20px;

    content: "";

    width: 100px;

    height: 0px;

    border: 1px solid black;

}

  

html:

<div >
    <h4>  <span class="onimg_title">买实惠</span></h4>
    <h5>热门促销</h5>
</div>

  

文字两边的横线实现