CSS设置table下只有tbody的展现滚动条,表头不动

直接上代码,大家可以参考下

<style type="text/css">
	table tbody {
	    display:block;
	    height:314px;
	    overflow-y:scroll;
	    -webkit-overflow-scrolling: touch; 
	}
	/* tbody的滚动条是否显示 */
	table tbody::-webkit-scrollbar {
	     display: block;
	 }
	table thead, tbody ,tfoot,tr {
	    display:table;
	    width:100%;
	    table-layout:fixed;
	}
	/* 	调节table的表头和下方表格的列是否能对齐 */
	table thead {
	    width: calc( 100% - 0.7em )
	}
	table thead th{ background:#ccc;}
	table tr td{
		height:72px;
	}
</style> 
 
<table  id="tables">
	<thead>
		<tr>
			<th>序号</th>
			<th>姓名</th>
			<th>性别</th>
			<th>年龄</th>
		</tr>
	</thead>
	<tbody id="data-items">
		<tr>
			<td></td>
			<td></td>
			<td></td>
			<td></td>
		</tr>
        <tr>
			<td></td>
			<td></td>
			<td></td>
			<td></td>
		</tr>
        <tr>
			<td></td>
			<td></td>
			<td></td>
			<td></td>
		</tr>
        <tr>
			<td></td>
			<td></td>
			<td></td>
			<td></td>
		</tr>
        <tr>
			<td></td>
			<td></td>
			<td></td>
			<td></td>
		</tr>
    </tbody>
	<tfoot>
		<tr>
			<td style="background: #f0f3f5;height:70px;">合计</td>
			<td colspan="2"  id="total" style='text-align: right;height:70px;'>0.00</td>
			<td align="center" style="background: #f0f3f5;height:70px;">金额合计(大写)</td>
			<td colspan="2" class="p-l-15 total" id="totalM" style="height:70px;">零元整</td>
		</tr>
	</tfoot>
</table>   
 
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值