表格根据内容自适应宽度样式设置

69 阅读1分钟
.table-wrapper {
  width: 100%;
  max-width: 100%;
  position: relative;
  border-radius: 8px;
  overflow-x: overlay;
  overflow-y: hidden;

  table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    overflow: auto;
    /* table-layout: fixed; */

    thead {
      th {
        height: 46px;
        line-height: 22px;
        text-align: left;
        padding: 12px 25px;
        color: rgba(0, 0, 0, 0.90);
        font-size: 14px;
        font-weight: 400;
        background: #F5F5F5;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
        max-width: 24rem;
        min-width: fit-content;
        overflow-wrap: break-word;

        .cell {
          white-space: nowrap;
          overflow: hidden;
          text-overflow: ellipsis;
        }
      }
    }

    tbody {
      width: 100%;

      tr {
        td {
          height: 54px;
          line-height: 22px;
          padding: 16px 25px 15px;
          color: rgba(0, 0, 0, 0.90);
          font-size: 14px;
          font-weight: 400;
          border-bottom: 1px solid #E7E7E7;
          max-width: 24rem;
          min-width: fit-content;
          overflow-wrap: break-word;

          .cell {
            white-space: nowrap;
            overflow: hidden;
            text-overflow: ellipsis;
          }

          .active-cell {
            display: inline-block;
            color: #3352F5;
            border-bottom: 1px solid #3352F5;
            cursor: pointer;
          }
        }
      }
    }
  }

  .empty-table {
    width: 100%;
    height: 150px;
    position: relative;

    .title {
      height: 46px;
      line-height: 22px;
      text-align: left;
      padding: 12px 25px;
      background: #F5F5F5;
    }

    .empty-content {
      height: 60px;
      line-height: 60px;
      text-align: center;
      margin-bottom: 20px;
      color: rgba(0, 0, 0, 0.45);
      font-size: 14px;
      font-weight: 400;
      text-align: center;
      border-bottom: 1px solid #E7E7E7;
      border-top: none;
      border-radius: 0px 0px 8px 8px;
    }
  }
}