SunSong

wxml:

<view class="section">
<view class="section__title">flex-direction: row</view>
<view class="flex-wrp" style="display:flex;flex-direction:row;">
<view class="flex-item bc_green">1</view>
<view class="flex-item bc_red">2</view>
<view class="flex-item bc_blue">3</view>
</view>
</view>
<view class="section">
<view class="section__title">flex-direction: column</view>
<view class="flex-wrp" style="flex-direction:column;display:flex;">
<view class="flex-item bc_green">1</view>
<view class="flex-item bc_red">2</view>
<view class="flex-item bc_blue">3</view>
</view>
</view>

 

wxss

.bc_green{background-color: green;width: 20%;text-align: center;}
.bc_red{background-color: red;width: 20%;text-align: center;}
.bc_blue{background-color: blue;width: 20%;text-align: center;}

 

注意:view的display是默认的block,要修改成flex才行

justify-content:space-around; 所有子内容居中显示,左右居中

 justify-content:space-between;子内容左右抵满,中间留空

flex-wrap:wrap;自动换行

flex-wrap:nowrap;不换行

分类:

技术点:

相关文章:

  • 2021-11-14
  • 2021-11-21
  • 2021-11-21
  • 2021-11-10
  • 2021-12-21
猜你喜欢
  • 2021-10-06
  • 2021-07-27
  • 2021-11-21
  • 2021-11-21
  • 2022-12-23
  • 2021-09-21
  • 2021-08-01
相关资源
相似解决方案