
实现最终效果
<!--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
本文介绍了如何使用微信小程序中的flex弹性布局,详细讲解了如何通过此布局方式实现元素的水平和垂直居中。同时,提供了一个flex布局的完整教程链接,帮助开发者深入理解这一技巧。
订阅专栏 解锁全文
1万+

被折叠的 条评论
为什么被折叠?



