前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >微信小程序----Gallery Table(图文表格)(flex布局实现MUI的图文表格)

微信小程序----Gallery Table(图文表格)(flex布局实现MUI的图文表格)

作者头像
Rattenking
发布2021-02-01 11:01:19
1.3K0
发布2021-02-01 11:01:19
举报
文章被收录于专栏:Rattenking

效果图

在这里插入图片描述
在这里插入图片描述

WXML

代码语言:javascript
复制
<view class="tui-row">
  <view class="tui-col tui-col-2">
    <view class="gallery-box">
      <image class="gallery-img" src="https://rattenking.gitee.io/stone/images/wx/images/4.jpg"></image>
      <text class="gallery-text">VUE实战</text>
    </view>
  </view>
  <view class="tui-col tui-col-2">
    <view class="gallery-box">
      <image class="gallery-img" src="https://rattenking.gitee.io/stone/images/wx/images/1.jpg"></image>
      <text class="gallery-text">ES6学习之路</text>
    </view>
  </view>
  <view class="tui-col tui-col-2">
    <view class="gallery-box">
      <image class="gallery-img" src="https://rattenking.gitee.io/stone/images/wx/images/2.jpg"></image>
      <text class="gallery-text">CSS实战</text>
    </view>
  </view>
  <view class="tui-col tui-col-2">
    <view class="gallery-box">
      <image class="gallery-img" src="https://rattenking.gitee.io/stone/images/wx/images/3.jpg"></image>
      <text class="gallery-text">VUE学习之路</text>
    </view>
  </view>
</view>

WXSS

代码语言:javascript
复制
.tui-row{
  padding: 5px;
  display: -webkit-flex;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
}
.tui-col-2 {
  width:50%;
  flex: 0 0 auto;
}

.gallery-box{
  padding: 5px;
}
.gallery-img{
  width: 100%;
  height: 200rpx;
}
.gallery-text{
  display: block;
  text-align: center;
  font-size: 30rpx;
  height: 80rpx;
  line-height: 80rpx;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

总结

1、使用flex进行布局要注意兼容性,所以采用:display: -webkit-flex;display: flex; 2、为了保证每排三个图标的两对对齐,采用:justify-content: space-between; 3、父元素必须设置flex-wrap: wrap;进行换行,否则会在一排展示; 4、每个子元素的宽度width: 50%;必须写出,否则会按照其占位大小分配; 5、每个子元素设置flex: 0 0 auto;否则某个子元素超出,会改变其他元素大小!

WXRUI体验二维码

本文参与 腾讯云自媒体同步曝光计划,分享自作者个人站点/博客。
原始发表:2019/02/22 ,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体同步曝光计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • 效果图
  • WXML
  • WXSS
  • 总结
  • WXRUI体验二维码
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档