其他分享
首页 > 其他分享> > css固定table表头

css固定table表头

作者:互联网

.table-container {
  width: 100%;
  height: 100%;
  overflow: auto;
}

/* 首列固定 */
.table-container thead tr > th:first-child,
.table-container tbody tr > td:first-child {
  position: sticky;
  left: 0;
  z-index: 1;
}

/* 表头固定 */
.table-container thead tr > th {
  position: sticky;
  top: 0;
  z-index: 2;
}

/* 表头首列强制最顶层 */
.table-container thead tr > th:first-child {
  z-index: 3;
}

 

标签:index,container,tr,表头,th,table,css
来源: https://www.cnblogs.com/fyiyy/p/16683274.html