效果:

当表格列数太多时,怎么实现表格的横向滚动

要点:在表格外加一层div,div宽固定

html:

          <div class="project-tests">
            <table>
              <tr v-for="arr in projectTests" v-bind:key="arr[0]">
                <td v-for="item in arr" v-bind:key="item">{{item}}</td>
              </tr>
            </table>
          </div>

postcss: 

div.project-tests {
    width: 100%;
    overflow-x:scroll;
    & table {
        border-collapse:collapse;
        & tr {
            height: 40px;
            &:nth-child(odd) {
                background-color: #FAFAFA;
            }
            &:first-child {
                background-color: #EEF1F6;
            }
            &:hover {
                background-color: #EEF1F6;
            }
        }
        & td {
            border: 1px solid #DFE6EC;
            padding:8px; 
            white-space:nowrap;
            text-overflow: ellipsis;
        }
    }
}

 

相关文章:

  • 2022-01-15
  • 2021-05-06
  • 2022-01-29
  • 2022-02-24
  • 2021-06-08
  • 2021-12-29
  • 2021-11-19
  • 2021-07-29
猜你喜欢
  • 2021-11-22
  • 2021-12-25
  • 2021-07-29
  • 2021-08-04
  • 2021-11-21
  • 2021-11-21
相关资源
相似解决方案