el-table\vxe-table深色背景Css样式

一、el-table

1、HTML
<div class="table">
  <el-table
    :data="tableData"
	:cell-class-name="tabCellClassName"
    :row-class-name="tabRowClassName"
    border>
    <!-- 序号 -->
    <el-table-column type="index" label="序号" width="50"></el-table-column>
    <!-- 表格内容 -->
    <el-table-column v-for="item in tableHead" :key="item.id" :label="item.label" :prop="item.key">
    </el-table-column>
  </el-table>
</table>

2、Script
<script>
export default {
  name: "table",
  components: {},
  props: {},
  data() {
    return {
      tableHead: [ 
        {
          id:1,
          key:"name",
          label:"姓名"
        },
        {
          id:2,
          key:"age",
          label:"年龄"
        },
        {
          id:3,
          key:"sex",
          label:"性别"
        },
      ],
      tableData: [
        {
          name: "张三",
          age: 18,
          sex: "男",
        },
      ],
    };
  },
  computed: {},
  created() {},
  mounted() {},
  methods: {
    // cell-class-name
    tabCellClassName({ column, columnIndex }) {
      column.index = columnIndex + 1;
    },

    // row-class-name
    tabRowClassName({ row, rowIndex }) {
      row.index = rowIndex + 1;
    },
  },
};
</script>

3、Css
.table{
  width:100%;
  height:100vh;
  background-color: rgba(#041a07, 0.7);

  /deep/ .el-table::before {
    background: #4caa81;
  }
  
  /deep/ .el-table::after {
    background: #4caa81;
  }
  
  /deep/ .el-table {
    width: 100%;
    height: 100%;
    background-color: transparent;
    border-color: #4caa81;
    display: flex;
    flex-direction: column;
  
    // 表头背景颜色设置
    & tr {
      background-color: transparent !important;
    }
  
    // th,td样式设置
    th,
    td {
      text-align: center;
      border-color: #4caa81;
      color: #fff;
      background-color: transparent !important;
    }
  
    .el-table__cell {
      padding: 5px 0px !important;
    }
  
    .cell {
      padding: 0px !important;
    }
  
    .el-table__body-wrapper {
      width: 100%;
      flex: 1;
      overflow-y: auto;
    }
  }
}

二、vxe-table

1、HTML
<template>
  <div class="VxeTable">
    <!-- 表格 -->
    <vxe-table
      ref="xTable"
      :loading="loading"
      show-overflow
      show-header-overflow
      height="90%"
      :row-config="{ isHover: true }"
      :data="tableData">
      >
      <vxe-column
        v-for="item in tableHead"
        :key="item.id"
        :field="item.key"
        :title="item.label">
      </vxe-column>
      <slot></slot>
    </vxe-table>
    
    <!-- 分页 -->
    <vxe-pager
      size="mini"
      :loading="loading"
      :current-page="tablePage.currentPage"
      :page-size="tablePage.pageSize"
      :page-sizes="tablePage.pageSizes"
      :total="tablePage.totalResult"
      :layouts="['PrevPage', 'JumpNumber', 'NextPage', 'Sizes', 'Total']"
      @page-change="handlePageChange">
    </vxe-pager>
  </div>
</template>

2、Script
<script>
export default {
  data() {
    return {
      loading: false,
      tablePage: {
        currentPage: 1,
        pageSize: 10,
        pageSizes: [5, 10, 15, 20],
        totalResult: 0,
      },
      tableHead: [ 
        {
          id:1,
          key:"name",
          label:"姓名"
        },
        {
          id:2,
          key:"age",
          label:"年龄"
        },
        {
          id:3,
          key:"sex",
          label:"性别"
        },
      ],
      tableData: [
        {
          name: "张三",
          age: 18,
          sex: "男",
        },
      ],
    };
  },
  props: {},
  methods: {
    // 页码改变
    handlePageChange({ type, pageSize, currentPage }) {
      console.log(`页码改变,类型:${type}, 页码:${currentPage}, 每页条数:${pageSize}`)
    },
  },
  created() {},
  mounted() {},
};
</script>

3、Css
<style lang="less" scoped>
.VxeTable {
  width: 100%;
  height: 100%;

  // 表格
  /deep/ .vxe-table {
    width: 100%;
    box-sizing: border-box;

    .vxe-table--border-line {
      border-color: #026133;
    }

    // 单元格样式
    .vxe-body--column,
    .vxe-footer--column,
    .vxe-header--column {
      background-image: none !important;
      border-bottom: 1px solid #026133 !important;
      color: #fff !important;
    }

    // 单元格文本居中
    .vxe-cell {
      display: flex;
      justify-content: center;
    }

    // 表头背景颜色
    .vxe-table--header-wrapper {
      background-color: #065730 !important;

      // 表头底部线条
      .vxe-table--header-border-line {
        border-bottom: none;
      }
    }

    // 表格内容、底部背景颜色
    .vxe-table--body-wrapper table,
    .vxe-table--footer-wrapper table {
      background-color: transparent !important;
    }

    .vxe-header--gutter {
      background-image: linear-gradient(#065730, #065730) !important;
    }

    // 行hover样式
    .vxe-body--row.row--hover {
      background: #06322d !important;
    }
  }

  // 分页
  /deep/ .vxe-pager {
    background-color: transparent !important;
    width: 100%;
    height: 10%;
    text-align: center;
    color: #fff !important;

    // 自定义样式
    .vxe-pager--prev-btn,
    .vxe-pager--num-btn,
    .vxe-pager--next-btn,
    .vxe-input--inner {
      background-color: transparent !important;
      border: 1px solid #026133;
      color: #fff !important;
    }

    // vxe-select获取焦点时边框颜色
    .vxe-input:not(.is--disabled).is--active .vxe-input--inner {
      border: 1px solid #026133;
    }

    // 上一页,下一页禁用时样式
    .vxe-pager--prev-btn.is--disabled,
    .vxe-pager--next-btn.is--disabled {
      background-color: #69706c !important;
      border-color: #69706c !important;
      color: #999 !important;
    }

    // 上一页、下一页、页码选中时样式
    .vxe-pager--prev-btn:not(.is--disabled):focus,
    .vxe-pager--num-btn:not(.is--disabled):focus,
    .vxe-pager--next-btn:not(.is--disabled):focus {
      box-shadow: none;
    }

    // 当前页码选中时样式
    .vxe-pager--num-btn.is--active {
      background-color: #026133 !important;
    }
  }
}
</style>

相关推荐

  1. el-table\vxe-table深色背景Css样式

    2024-04-03 06:32:02       37 阅读
  2. el-table

    2024-04-03 06:32:02       35 阅读
  3. el-table vxe-table 表格宽度拖拽

    2024-04-03 06:32:02       31 阅读
  4. el-table点击每一行加背景颜色

    2024-04-03 06:32:02       61 阅读

最近更新

  1. docker php8.1+nginx base 镜像 dockerfile 配置

    2024-04-03 06:32:02       94 阅读
  2. Could not load dynamic library ‘cudart64_100.dll‘

    2024-04-03 06:32:02       101 阅读
  3. 在Django里面运行非项目文件

    2024-04-03 06:32:02       82 阅读
  4. Python语言-面向对象

    2024-04-03 06:32:02       91 阅读

热门阅读

  1. 回溯大学生活

    2024-04-03 06:32:02       34 阅读
  2. FPGA简介

    2024-04-03 06:32:02       39 阅读
  3. 2、趁热打铁,Docker实战

    2024-04-03 06:32:02       41 阅读
  4. 设计模式之桥接模式

    2024-04-03 06:32:02       43 阅读
  5. 全球化浪潮下的技术与安全

    2024-04-03 06:32:02       38 阅读
  6. 有哪些常见的网络安全威胁?

    2024-04-03 06:32:02       42 阅读
  7. Spring Boot项目中如何对Bean进行校验

    2024-04-03 06:32:02       41 阅读
  8. Spring Boot 热部署配置

    2024-04-03 06:32:02       40 阅读
  9. centos安装Rust

    2024-04-03 06:32:02       38 阅读
  10. Android adb 常用命令

    2024-04-03 06:32:02       40 阅读
  11. 深入理解Spring Boot Controller层的作用与搭建过程

    2024-04-03 06:32:02       38 阅读
  12. el-table的复选框勾选整行变色

    2024-04-03 06:32:02       35 阅读