第一句子网 - 唯美句子、句子迷、好句子大全
第一句子网 > 微信小程序——flex弹性布局水平垂直居中

微信小程序——flex弹性布局水平垂直居中

时间:2020-06-03 07:33:19

相关推荐

微信小程序——flex弹性布局水平垂直居中

实现最终效果

<!--index.wxml--><view class="body"><view class="out"><view class='in'><text>in</text></view></view></view>

/**index.wxss**/.body{display: flex;justify-content: center; /* 水平居中 */align-items: center; /* 垂直居中 */}.out {width: 400rpx;height: 300rpx;background-color: blue;display: flex;justify-content: center; /* 水平居中 */align-items: center; /* 垂直居中 */}.in {width: 150rpx;height: 100rpx;background-color: red;}text{font-size: 28px;display: flex;justify-content: center; /* 水平居中 */align-items: center; /* 垂直居中 */}

css将下面三行从text移动到in中依旧可以实现文字in居中

display: flex;justify-content: center; /* 水平居中 */align-items: center; /* 垂直居中 */

flex布局完整教程链接

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。