0
点赞
收藏
分享

微信扫一扫

微信小程序 文字居中

奔跑的酆 2023-03-14 阅读 97


1 有宽高 line-height

<view class='container'>
666
</view>

.container{
border: 2rpx black solid;
width: 400rpx;
height: 200rpx;
text-align: center; /* 左右居中 */
line-height: 200rpx; /* 设置行高 使文字上下居中 */
}

2 使用flex布局

<view class='container'>
<text>666</text>
</view>

.container{
border: 2rpx solid red;
width: 500rpx;
height: 200rpx;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
}


举报

相关推荐

0 条评论