如何将文字设置在水平线中间?

类似这样

https://img1.mukewang.com/5bdea12c0001429602510016.jpg

子衿沉夜
浏览 801回答 1
1回答

白猪掌柜的

试试下面这个,看看是不是你想要的<!DOCTYPE html><html><head>&nbsp; <meta charset="UTF-8">&nbsp; <title>Document</title>&nbsp; <style>&nbsp; &nbsp; .title{&nbsp; &nbsp; &nbsp; text-align: center;&nbsp; &nbsp; &nbsp; overflow: hidden;&nbsp; &nbsp; }&nbsp; &nbsp; .title span{&nbsp; &nbsp; &nbsp; position: relative;&nbsp; &nbsp; &nbsp; display: inline-block;&nbsp; &nbsp; }&nbsp; &nbsp; .title span::before{&nbsp; &nbsp; &nbsp; content: '';&nbsp; &nbsp; &nbsp; position: absolute;&nbsp; &nbsp; &nbsp; top: 50%;&nbsp; &nbsp; &nbsp; width: 1000px;&nbsp; &nbsp; &nbsp; height: 1px;&nbsp; &nbsp; &nbsp; left: 100%;&nbsp; &nbsp; &nbsp; background-color: #333;&nbsp; &nbsp; }&nbsp; &nbsp; .title span::after{&nbsp; &nbsp; &nbsp; content: '';&nbsp; &nbsp; &nbsp; position: absolute;&nbsp; &nbsp; &nbsp; top: 50%;&nbsp; &nbsp; &nbsp; right: 100%;&nbsp; &nbsp; &nbsp; width: 1000px;&nbsp; &nbsp; &nbsp; height: 1px;&nbsp; &nbsp; &nbsp; background-color: #333;&nbsp; &nbsp; }&nbsp; </style></head><body>&nbsp; <div class="title"><span>测试文字</span></div></body></html>
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

JavaScript