大家都知道微信小程序自身没有提供表格这个组件,但是今天的项目需求又出现了,所以只能模仿一个了。
效果图:
代码挺简单方便的:
wxml:
<view class='history-table-wrap'>
<view class="table">
<view class="tr">
<view class="th th1">日期</view>
<view class="th th2">时间</view>
<view class="th th3">伤害</view>
</view>
<view class="tr" wx:for="{{15}}">
<view class="td td1">2018/02/12</view>
<view class="td td2">11:30</view>
<view class="td td3">本次对海煞造成了100000点伤害</view>
</view>
</view>
</view>
wxss:
.history-table-wrap{
position: absolute;
width: 668rpx;
height: 578rpx;
left: 50%;
margin-left: -334rpx;
top: 70rpx;
overflow-y: scroll;
overflow-x: hidden;
}
/* 表格代码 */
.table{
border:1px solid #dadada;
border-right:0;
border-bottom: 0;
width: 98%;
margin-left: 1%;
}
.tr{
width:100%;
display: flex;
justify-content: space-between;
}
.th,.td{
padding: 10px;
border-bottom: 1px solid #dadada;
border-right: 1px solid #dadada;
text-align: center;
width: 100%;
}
.th1,.th2,.td1,.td2{
width: 40%;
}
.th{
font-weight: 800;
background-color: #b66242;
font-size: 28rpx;
color: #330e0e;
}
.td{
font-size: 20rpx;
color: #ec9480;
}