JSFiddle - React, Tailwind, and code Playground
by hcy520
HTML
<div class="wrapbox">
<div class="table-head">
<table>
<thead>
<th width="10%">合同号</th>
<th width="30%">签约客户</th>
<th width="20%">发布客户</th>
<th width="10%">合同状态</th>
<th width="30%">选定条件的发布周期额度</th>
</thead>
</table>
</div>
<div class="table-body">
<table>
<tbody id="tbody">
</tbody>
</table>
</div>
</div>
CSS
*{
padding:0;
margin:0;
}
th{
border:1px solid #e6e6e6;
line-height: 5vh;
color:#666666;
font-size: 16px;
}
table {
border-collapse: collapse;
width: 100%;
}
td {
padding:5px;
border:1px solid #e6e6e6;
font-size: 14px;
}
.table-head{padding-right:17px;background-color:rgb(207, 231, 179);color:#000;height:5vh;}
.table-body{width:100%; height:94vh;overflow-y:scroll;}
.table-head table,.table-body table{width:100%;}
.table-body table tr:nth-child(2n+1){background-color:#f2f2f2;}
.table-body table tr:hover {
background-color:rgb(240, 249, 228);
transition: .2s;
}
JavaScript
buildBody();
function buildBody() {
var trs = '';
for(var i = 0; i< 500; i++){
trs += " <tr>" +
" <td width='10%' style='text-decoration:underline;cursor: pointer' onclick='handle(\""+i+"\")'>"+ i +"</td>" +
" <td width='30%'>"+ i +'签约客户' +"</td>" +
" <td width='20%'>"+ i +'发布客户'+"</td>" +
" <td width='10%'>"+ i +'合同状态' +"</td>" +
" <td width='30%'>"+ i +'选定条件'+"</td>" +
" </tr>"
}
document.getElementById('tbody').innerHTML = trs ;
}