1
<!-- wxml -->
<view class="father center">
  <view class="children1">块1</view>
  <view class="children2">块2</view>
  <view class="children3">块3</view>
</view>
/* wxss */
.father{
  width: 100%;
  height: 300rpx;
  background-color: #FFFFCC;
}

.children1{
  background-color: #99CCCC;
}

.children2{
  background-color: #FFCC99;
}

.children3{
  background-color: #FFCCCC;
}

原始效果:
原始效果

1 水平居中

1.1 水平居中&水平排列

/* wxss */
.center1{
  width: 100%;
  height: 300rpx;
  display: flex;
  justify-content: center;
}

效果:
水平居中&水平排列

1.2 水平居中&垂直排列

/* wxss */
.center2{
  width: 100%;
  height: 300rpx;
  display: flex;
  flex-direction: column;
  align-items: center;
}

效果:
水平居中&垂直排列

2 垂直居中

2.1 垂直居中&水平排列

/* wxss */
.center3{
  width: 100%;
  height: 300rpx;
  display: flex;
  align-items: center;
}

效果:
垂直居中&水平排列

2.2 垂直居中&垂直排列

/* wxss */
.center4{
  width: 100%;
  height: 300rpx;
  display: flex;
  flex-direction:column;
  justify-content: center;
}

效果:
垂直居中&垂直排列

3 中心居中

3.1 中心居中&水平排列

/* wxss */
.center5{
  width: 100%;
  height: 300rpx;
  display: flex;
  align-items: center;
  justify-content: center;
}

效果:
中心居中&水平排列

3.2 中心居中&垂直排列

/* wxss */
.center6{
  width: 100%;
  height: 300rpx;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

效果:
中心居中&垂直排列

关于容器的属性,自己去查吧hiahiahia~


Ni256o
1 声望2 粉丝

这个人很懒,什么都没有留下...