CSS伪类before,after制作左右横线文字效果
发布时间 | 2016/12/3 点击 | 次
1,这种方法比利用边框和背景图做出的效果更好更利于控制和修改
2,缺点是伪类在IE8上兼容有些问题
.container{width: 1000px; margin: 10px auto; border: 1px solid red;} h3.title {color:#F2AE11;font-size:1.3em;margin-bottom:3em;text-align:center;font-weight:500; line-height:1.1;} h3.title span {display: block; font-size: 3em;color: #212121;position: relative;} h3.title span:before, h3.title span:after {content: ''; position: absolute; top: 52%;background: #494949; width: 9%;height: 2px;} h3.title span:before{left: 25%; } h3.title span:after {right: 25%;}
<div class="container"> <h3 class="title">Welcome to <span>www.021jz.com.cn</span></h3> </div>