Skip to content

Flex 布局

示例

html
<view class="flex">
  <view></view>
  <view></view>
</view>

示例

html
<view class="flex flex-col">
  <view></view>
  <view></view>
</view>

示例

html
<view class="flex items-center">
  <view></view>
  <view></view>
</view>

示例

html
<view class="flex items-center justify-between">
  <view></view>
  <view></view>
</view>
类名属性
flexdisplay: flex
inline-flexdisplay: inline-flex

  
flex-rowflex-direction: row
flex-row-reverseflex-direction: row-reverse
flex-colflex-direction: column
flex-col-reverseflex-direction: column-reverse

  
flex-wrapflex-wrap: wrap
flex-wrap-reverseflex-wrap: wrap-reverse
flex-nowrapflex-wrap: nowrap

  
flex-shrink-0flex-shrink: 0

  
justify-startjustify-content: flex-start
justify-endjustify-content: flex-end
justify-centerjustify-content: center
justify-betweenjustify-content: space-between
justify-aroundjustify-content: space-around
justify-evenlyjustify-content: space-evenly

  
items-startalign-items: flex-start
items-endalign-items: flex-end
items-centeralign-items: center
items-baselinealign-items: baseline
items-stretchalign-items: stretch

  
justify-self-autojustify-self: auto
justify-self-startjustify-self: start
justify-self-endjustify-self: end
justify-self-centerjustify-self: center
justify-self-baselinejustify-self: baseline
justify-self-stretchjustify-self: stretch

  
content-startalign-content: flex-start
content-endalign-content: flex-end
content-centeralign-content: center
content-betweenalign-content: space-between
content-aroundalign-content: space-around
content-evenlyalign-content: space-evenly

  
self-autoalign-self: auto
self-startalign-self: flex-start
self-endalign-self: flex-end
self-centeralign-self: center
self-baselinealign-self: baseline
self-stretchalign-self: stretch