table 滚动时固定表头

表格内容过多时,仅滚动数据,表头不动

  table {
    height: 100%;
    overflow: auto;
    table-layout: fixed;
    display: block;

    & > thead {
      position: sticky;
      top: 0;
      left: 0;
      right: 0;
      display: table;
      width: 100%;
      table-layout: fixed;
      z-index: 1;
    }

    & > tbody {
      display: table;
      width: 100%;
      table-layout: fixed;
    }
  }

 表格html:

暂无数据

你可能感兴趣的:(前端,javascript,vue)