在table父级元素中设置 overflow-y: auto;overflow-x: hidden;
保持table父级元素和table大小相同;
<div style="border-bottom:1px solid #aaa;height: 1px;width:300px ;"></div>
<div style=" height:200px;width:300px;overflow-y: auto;overflow-x: hidden;">
<table style="height:200px;width:300px;text-align: center;border: 1px solid #aaa;"
frame="border" rules="all">
<thead style="width:100%">
<tr style="height:60px;position:sticky;top: -1px;background: #e8e8e8;">
<td style="width:60%">公司名称</td>
<td style="width:40%">用电量</td>
</tr>
</thead>
<tbody style="width:100%">
<tr style="height:50px">
<td>沙河市安全实业有限公司</td>
<td>23652.0328 kw</td>
</tr>
<tr style="height:50px">
<td>沙河市安全实业有限公司</td>
<td>23652.0328 kw</td>
</tr>
<tr style="height:50px">
<td>沙河市安全实业有限公司</td>
<td>23652.0328 kw</td>
</tr>
<tr style="height:50px">
<td>沙河市安全实业有限公司</td>
<td>23652.0328 kw</td>
</tr>
<tr style="height:50px">
<td>沙河市安全实业有限公司</td>
<td>23652.0328 kw</td>
</tr>
</tbody>
</table>
</div>
<div style="border-bottom:1px solid #aaa;height: 1px;width:300px ;"></div>