其他分享
首页 > 其他分享> > css固定头部和首列

css固定头部和首列

作者:互联网

.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,th,tr,头部,首列,table,css,thead
来源: https://blog.csdn.net/weixin_44252277/article/details/123635928