首先是css的样式,根据自己页面再调整宽高之类的属性,这里是我自己页面的:
table { table-layout:fixed; }
th { position:-webkit-sticky; position:sticky; }
thead tr th { top:0; }
thead tr th:first-of-type { left:0; z-index:1; width:200px}
tbody th { left:0; width:200px}
th, td {
text-align:center;
vertical-align:middle;
width:150px;
}
th {
padding:10px;
}
再就是html标签
表格头table>thead>tr>th(第一个th标签加上 scope=“col”)
表格主体tbody>tr>(第一个用th标签,后面的就是td标签,th标签加上 scope=“row” )
table表格实现第一列固定
最新推荐文章于 2024-06-14 16:28:37 发布