Skip to content

Grid 布局

示例

html
<view class="grid grid-cols-6 gap-20">
  <view></view>
  <view></view>
  <view></view>
  <view></view>
  <view></view>
  <view></view>
</view>

<view class="grid grid-cols-3 gap-20">
  <view class="col-span-2"></view>
  <view class="col-start-4"></view>
  <view></view>
</view>

类名属性
griddisplay: grid

  
grid-cols-${x}(0-12)grid-template-columns: repeat(${x}, minmax(0, 1fr))

  
grid-rows-${x}(0-6)grid-template-rows: repeat(${x}, minmax(0, 1fr))

  
col-span-${x}(1-12)grid-column: span ${x} / span ${x};
col-span-autogrid-column: auto;
col-span-fullgrid-column: 1 / -1;
row-span-${x}(1-12)grid-row: span ${x} / span ${x};
row-span-autogrid-row: auto;
row-span-fullgrid-row: 1 / -1;

  
col-start-${x}(0-13)grid-column-start: ${x};
row-start-${x}(0-13)grid-row-start: ${x};

  
col-end-${x}(0-13)grid-column-end: ${x};
row-end-${x}(0-13)grid-row-end: ${x};

  
gap-${x}(0-30)gap: ${x};
gap-x-${x}(0-30)column-gap: ${x};
gap-y-${x}(0-30)row-gap: ${x};