微信小程序创建表格

微信小程序创建表格

今天小编遇到了这样一个需求,用户想要列表信息,找了好多地方,才发现微信没有H5中的table标签,所以自己画了一个表格。发现效果还不错,分享给大家。以下是我的效果图(内容仅为参考):

以下是这个样式的wxml代码:

<view class="table" >

    <view class="tab_th">

        <view class="th_td1 th_text"><text>序号</text></view>

        <view class="th_td2 th_text"><text>姓名</text></view>

        <view class="th_td3 th_text"><text>性别</text></view>

        <view class="th_td4 th_text"><text>备注</text></view>

    </view>

    <block >

    <view class="tab_tr">

        <view class="tr_td1 text"><text>1</text></view>

        <view class="tr_td2 text"><text>张飞</text></view>

        <view class="tr_td3 text"><text>男</text></view>

        <view class="tr_td4 text"><text>已婚</text></view>

    </view>

    <view class="tab_tr">

        <view class="tr_td1 text"><text>2</text></view>

        <view class="tr_td2 text"><text>关羽</text></view>

        <view class="tr_td3 text"><text>男</text></view>
    
        <view class="tr_td4 text"><text>已婚</text></view>

    </view>

    <view class="tab_tr">

        <view class="tr_td1 text"><text>3</text></view>

        <view class="tr_td2 text"><text>刘备</text></view>

        <view class="tr_td3 text"><text>男</text></view>

        <view class="tr_td4 text"><text>已婚</text></view>

    </view>
    
    <view class="tab_tr">

        <view class="tr_td1 text"><text>4</text></view>

        <view class="tr_td2 text"><text>赵云</text></view>

        <view class="tr_td3 text"><text>男</text></view>

        <view class="tr_td4 text"><text>已婚</text></view>

    </view>

</block>

</view>

 

下面是wxss代码:

.table{

    width: 98%;

    border-top: #E8E8E8 solid 1px;

    border-bottom: #E8E8E8 solid 1px;

    position: relative;

    left: 1%;

    color: #333333;

}

.tab_th{

    width: 100%;

    position: relative;

    height: 70rpx;

    border-top: #E8E8E8 solid 1px;

    border-bottom: #E8E8E8 solid 1px;

    background-color: #FAFAFA;

    display: flex;

    align-items: center;
    
    justify-content: center;

}

.th_td1{

    width: 15%;

    height: 70rpx;

    border-top: #E8E8E8 solid 1px;

    border-bottom: #E8E8E8 solid 1px;

    background-color: #FAFAFA;

    display: flex;

    align-items: center;

    justify-content: center;

}

.th_td2{

    width: 40%;

    height: 70rpx;

    border: 1px solid #E8E8E8;

    background-color: #FAFAFA;

    display: flex;

    align-items: center;

    justify-content: center;

}

.th_td3{
    
    width: 25%;

    height: 70rpx;

    border: 1px solid #E8E8E8;

    background-color: #FAFAFA;

    display: flex;

    align-items: center;

    justify-content: center;

}

.th_td4{

    width: 20%;

    height: 70rpx;

    border-top: #E8E8E8 solid 1px;

    border-bottom: #E8E8E8 solid 1px;

    background-color: #FAFAFA;

    display: flex;

    align-items: center;

    justify-content: center;

}

.tab_tr{

    width: 100%;

    position: relative;

    height: 70rpx;

    border-top: #E8E8E8 solid 1px;

    border-bottom: #E8E8E8 solid 1px;

    background-color: #FFFFFF;

    display: flex;

    align-items: center;

    justify-content: center;

}

.tr_td1{

    width: 15%;

    height: 70rpx;

    border-top: #E8E8E8 solid 1px;

    border-bottom: #E8E8E8 solid 1px;

    background-color: #FFFFFF;

    display: flex;

    align-items: center;

    justify-content: center;

}

.tr_td2{

    width: 40%;

    height: 70rpx;

    border: 1px solid #E8E8E8;

    background-color:#FFFFFF;

    display: flex;

    align-items: center;
    
    justify-content: center;

}

.tr_td3{

    width: 25%;

    height: 70rpx;

    border: 1px solid#E8E8E8;

    background-color: #FFFFFF;

    display: flex;

    align-items: center;

    justify-content: center;

}

.tr_td4{

    width: 20%;

    height: 70rpx;

    border-top: #E8E8E8 solid 1px;

    border-bottom: #E8E8E8 solid 1px;

    background-color: #FFFFFF;

    display: flex;

    align-items: center;

    justify-content: center;

}

.text{

    font-size:12px;

    font-family:PingFangHK-Regular,PingFangHK;
    
    font-weight:400;

    color:rgba(51,51,51,1);

    line-height:17px;

}

.th_text{

    font-size:16px;

    font-family:PingFangSC-Regular,PingFang SC;

    font-weight:400;

    color:rgba(51,51,51,1);

    line-height:22px;

}

 

希望可以帮助到大家,样式仅为参考,大家其实可以自己动手画一个表格,说不定更好!

  • 6
    点赞
  • 23
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值