效果图
实现代码
方法1 简单点的
wxml
<view >
<text class='reason_txt'>入网的理由</text>
</view>
wxss
.reason_txt{
font-size: 32rpx;
color: #333333;
display: table;
width: auto;
white-space: nowrap;
border-spacing: 0.5rem 0;
margin-left: 28rpx;
margin-right: 28rpx;
}
.reason_txt::before,.reason_txt::after{
display: table-cell;
content: "";
width: 50%;
background: linear-gradient(#D8D8D8, #D8D8D8) repeat-x center;
background-size: 0.1rem 0.1rem;
}
若果想修改线的长度修改border-spacing: 0.5rem 0; 的值即可
方法二:麻烦点的
wxml代码如下
<view class='main_view'>
<text class='befor'></text>
<text class='reason_txt'>入网的理由</text>
<text class='after'></text>
</view>
wxss 代码如下
.main_view{
display: flex;
flex-direction: row;
justify-content: space-around;
width: 100%;
height: 60rpx;
margin-top: 100rpx;
}
.befor{
width: 200rpx;
height: 1rpx;
background: #333333;
line-height: 60rpx;
}
.after{
width: 200rpx;
height: 1rpx;
background: #333333;
line-height: 60rpx;
}
.reason_txt{
position: relative;
margin-top: -28rpx;
}