微信小程序自己开发了一套 wxml + wxss,对许多 HTML 标签和 CSS 属性不支持。
 
不支持 table 标签,推荐使用 flex 布局。
 
自然而然的想法:flex 嵌套,效果还不错,贴代码如下:
 
Flex 实现表格布局 (微信小程序)
<view id="panel" class="flex-column">
  <view class="flex-cell flex-row">
    <text class="flex-cell flex-row">1</text>
    <text class="flex-cell flex-row">2</text>
    <text class="flex-cell flex-row">3</text>
    <text class="flex-cell flex-row">4</text>
  </view>
  <view class="flex-row flex-cell">
    <text class="flex-cell flex-row">1</text>
    <text class="flex-cell flex-row">2</text>
    <text class="flex-cell flex-row">3</text>
    <text class="flex-cell flex-row">4</text>
  </view>
  <view class="flex-row flex-cell">
    <text class="flex-cell flex-row">1</text>
    <text class="flex-cell flex-row">2</text>
    <text class="flex-cell flex-row">3</text>
    <text class="flex-cell flex-row">4</text>
  </view>
  <view class="flex-row flex-cell">
    <text class="flex-cell flex-row">1</text>
    <text class="flex-cell flex-row">2</text>
    <text class="flex-cell flex-row">3</text>
    <text class="flex-cell flex-row">4</text>
  </view>
  <view class="flex-row flex-cell">
    <text class="flex-cell flex-row">1</text>
    <text class="flex-cell flex-row">2</text>
    <text class="flex-cell flex-row">3</text>
    <text class="flex-cell flex-row">4</text>
  </view>

</view>
Flex 实现表格布局 (微信小程序)
Flex 实现表格布局 (微信小程序)
#panel{
  height:65vh;
  background:#fff;
}

#panel text{
  line-height: 13vh;
  border-right: 1rpx solid #ddd;
  border-bottom: 1rpx solid #ddd;
}

.flex-row{
  display: flex;
  flex-direction: row;
  justify-content: center;
  align-items: center;
}
.flex-column{
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: stretch;
}

.flex-cell{
  flex: 1;
}
Flex 实现表格布局 (微信小程序)

Flex 实现表格布局 (微信小程序)

相关文章:

  • 2021-10-31
  • 2021-09-21
  • 2021-08-01
  • 2021-11-21
  • 2021-11-21
  • 2021-11-21
  • 2021-11-21
猜你喜欢
  • 2021-11-21
  • 2021-11-16
  • 2021-11-29
  • 2021-07-13
  • 2021-12-24
  • 2022-12-23
相关资源
相似解决方案