87,910
社区成员
发帖
与我相关
我的任务
分享
<script src="http://cdn.bootcss.com/jquery/3.2.1/jquery.min.js"></script>
<style type="text/css">
table tbody {
display: block;
height: 195px;
overflow-y: scroll;
}
table thead, tbody tr {
display: table;
table-layout:fixed;
}
table {
width: 300px;
height: 150px;
}
/*总宽度除以总列数等于列宽300/3=100*/
table tr td,th{
text-align: center;
width: 100px;
}
</style>
<table>
<thead>
<th>head1</th>
<th>head2</th>
<th>head3</th>
</thead>
<tbody class='info'></tbody>
</table>
let tr = [];
for(var i = 0; i<10; i++){
tr.push('<tr><td>'+i+'1</td><td>'+i+'2</td><td>'+i+'3</td></tr>');
}
$('.info').html(tr.join(''));