当前位置:   article > 正文

ElementUI样式优化:el-input修改样式、el-table 修改表头样式、斑马格样式、修改滚动条样式、_el-input 样式

el-input 样式

效果图: 

1、改变日期时间组件的字体颜色背景

.form-class ::v-deep .el-date-editor {

    border: 1px solid #326AFF;

    background: #04308D !important;

  }

  .form-class ::v-deep .el-date-editor.el-input__wrapper {

    box-shadow: 0 0 0 0px #326AFF inset;

  }

// 输入框

  .form-class ::v-deep .el-date-editor .el-range-input{

    background: #04308D !important;

    font-size: 14px;

    font-family: PingFang SC, PingFang SC;

    font-weight: 400;

    color: #FFFFFF;

  }

//   中间的至字

  .form-class ::v-deep  .el-date-editor .el-range-separator{

    background: #04308D !important;

    color: #FFFFFF;

  }

.form-class ::v-deep   .el-range__close-icon{

    background: #04308D !important;

    color: #FFFFFF;

  }

修改element-ui日期下拉框datetimePicker的背景色样式-CSDN博客 弹窗样式在这里

2、修改input的字体颜色背景

   // 输入框

  .form-class ::v-deep .el-input__wrapper {

    border: 1px solid #326AFF;

    box-shadow: 0 0 0 0px #326AFF inset;

    background: #04308D !important;

  }    

     // 输入框

   ::v-deep  .el-input__inner{

        background: #04308D !important;

        font-size: 14px;

        font-weight: 400;

        color: #FFFFFF;

      }  

3、修改按钮颜色

.blue-button{

  background-color: #326aff;

  border: 1px solid #326AFF;

}

4、去表格的白线

.el-table{

    // 去掉白线

    --el-table-border-color:#063570;

}

不写就会有如下白线 

 5、设置表格行高度

 // 设置表格行高度

::v-deep .el-table__body tr,

::v-deep .el-table__body td {

  padding: 0;

  height: 40px;

}

6、表格内背景颜色

// 表格内背景颜色

::v-deep .el-table th,

::v-deep .el-table tr,

::v-deep .el-table td {

  background-color:#063570;  

  border: 0px;

  color: #fff;  // 修改字体颜色

  font-size: 24px;

  height: 5px;

  font-weight: Normal;

}

7、 修改表头样式-加边框 和背景色

  // 修改表头样式-加边框

::v-deep .el-table__header-wrapper {

    border: solid 1px #00429c;

    // box-sizing: border-box;

  }

   // 修改表头样式-背景色

  ::v-deep .el-table__header thead tr th{

    border: #002C69 0px solid;  

    background: linear-gradient(to top, #0085FB, #002C69)!important;

    color: #FFFFFF;

  }

8、 表格斑马自定义颜色 

表格部分 

<el-table :data="tableData" height="55vh" :row-class-name="tableRowClassName"

js部分添加 

const tableRowClassName = ({ row, rowIndex }) => {

  if (rowIndex % 2 == 0) {

    return "warning-row1";

  } else {

    return "warning-row2";

  }

}

  // 表格斑马自定义颜色

::v-deep .el-table__row.warning-row1 {

    background: #03367c;

    border: #002C69 0px solid;

    color: #FFFFFF;

}

  ::v-deep .el-table__row.warning-row2 {

    background: #002C69;

    border: #002C69 0px solid;

    color: #FFFFFF;

}

9、鼠标悬停行颜色改变

<style>

/* 用来设置当前页面element全局table 选中某行时的背景色*/

/*鼠标移入某行时的背景色*/

.el-table--enable-row-hover .el-table__body tr:hover>td {

  background-color: #0873fd !important;

  /* 设置鼠标悬停时的背景色 */

  color: black !important;

  /* 设置文字颜色 */

}

</style>

补充:暂无数据时的表格背景颜色

::v-deep .el-table__empty-block{

    background-color: #063570;

    color: #fff; // 修改字体颜色

}

10、滚动条的样式

  // 滚动条样式

::v-deep .el-table__body-wrapper::-webkit-scrollbar-track {

    background-color: #063570;

  }

  ::v-deep .el-table__body-wrapper::-webkit-scrollbar {

    width: 10px;

    opacity: 0.5;

  }

  ::v-deep .el-table__body-wrapper::-webkit-scrollbar-thumb {

    border-radius: 15px;

    background-color: #0257aa;

  }

11、分页样式

  1. // 分页
  2. ::v-deep .pagination-container{
  3. background: #063570!important;
  4. }
  5. //这是123454
  6. ::v-deep .el-pager li{
  7. border: 1px solid #326AFF;
  8. background: #04308D !important;
  9. color: #FFFFFF;
  10. }
  11. ::v-deep .el-pager li.is-active{
  12. background: #0873fd !important;
  13. }
  14. // <这个
  15. ::v-deep .btn-prev {
  16. // border: 1px solid #326AFF;
  17. background-color: #04308D !important;
  18. color: #FFFFFF;
  19. }
  20. // >这个
  21. ::v-deep .btn-next {
  22. // border: 1px solid #326AFF;
  23. background-color: #04308D !important;
  24. color: #FFFFFF;
  25. }
  26. // 前往
  27. ::v-deep .el-pagination__jump .el-pagination__goto{
  28. color: #FFFFFF;
  29. }
  30. // 页码筛选的input
  31. ::v-deep .el-pagination__jump .el-input{
  32. border: 1px solid #326AFF;
  33. background: #04308D !important;
  34. color: #FFFFFF;
  35. }
  36. ::v-deep .el-pagination__jump .el-input .el-input__wrapper{
  37. // border: 1px solid #326AFF;
  38. background: #04308D !important;
  39. box-shadow: 0 0 0 0px #326AFF inset;
  40. color: #FFFFFF;
  41. }
  42. // 页
  43. ::v-deep .el-pagination__jump .el-pagination__classifier{
  44. color: #FFFFFF;
  45. }
  46. // el-input el-input--default el-pagination__editor is-in-pagination

 12、总代码 

  1. <el-dialog class="blue-dialog" v-model="dialogVisible" title="工单列表" width="80%" custom-class="openAnimAbcd" draggable>
  2. <el-form :inline="true" :model="queryParams" ref="queryParamsRef" class="demo-form-inline form-class"
  3. label-width="68px">
  4. <el-form-item label="时间筛选" prop="time">
  5. <el-date-picker class="custom-timeselect" v-model="time" type="datetimerange" range-separator="至"
  6. start-placeholder="开始时间" end-placeholder="结束时间" style="width: 380px" value-format="YYYY-MM-DD HH:mm:ss"
  7. :shortcuts="shortcuts" @change="changetime" :default-time="defaultTime" />
  8. </el-form-item>
  9. <el-form-item label="输入框" prop="time">
  10. <el-input style="width: 70px" v-model="queryParams.number1" placeholder="请输入" :error="durationInputError(queryParams.number1)"
  11. @input="handleDurationInput1(queryParams.number1)"></el-input>&nbsp;
  12. <span style=" color: #FFFFFF"></span>
  13. &nbsp;
  14. <el-input style="width: 70px" v-model="queryParams.number2" placeholder="请输入"
  15. :error="durationInputError(queryParams.number2)"
  16. @input="handleDurationInput2(queryParams.number2)"></el-input>
  17. </el-form-item>
  18. <el-form-item>
  19. <el-button type="primary" class="blue-button" size="Small" @click="handleExport">导出</el-button>
  20. <el-button type="primary" class="blue-button" @click="resetQuery" size="Small">重置</el-button>
  21. <el-button type="primary" size="Small" class="blue-button" @click="getecharstData">搜索</el-button>
  22. </el-form-item>
  23. </el-form>
  24. <el-table :data="tableData" height="55vh" :row-class-name="tableRowClassName" key='xqtable'
  25. :highlight-current-row="false">
  26. <el-table-column prop="name" label="名字" min-width="80" />
  27. <el-table-column prop="name" label="名字" min-width="80" />
  28. <el-table-column prop="name" label="名字" min-width="80" />
  29. <el-table-column prop="name" label="名字" min-width="80" />
  30. <el-table-column prop="name" label="名字" min-width="80" />
  31. <el-table-column prop="name" label="名字" min-width="80" />
  32. <el-table-column prop="name" label="名字" min-width="80" />
  33. <el-table-column prop="name" label="名字" min-width="80" />
  34. <el-table-column prop="name" label="名字" min-width="80" />
  35. <el-table-column prop="name" label="名字" min-width="80" />
  36. </el-table>
  37. <pagination :page-sizes="[100, 200, 500, 1000, 2000, 5000]" v-show="total > 0" :total="total" class="paginationyhd"
  38. v-model:page="queryParams.pageNum" v-model:limit="queryParams.pageSize" @pagination="openTable" />
  39. </el-dialog>

 js部分

const tableRowClassName = ({ row, rowIndex }) => {

  if (rowIndex % 2 == 0) {

    return "warning-row1";

  } else {

    return "warning-row2";

  }

}

样式引入

<style src="@/assets/styles/dialog.scss" scoped />

<style>

.el-table--enable-row-hover .el-table__body tr:hover>td {

  background-color: #0873fd !important;

  /* 设置鼠标悬停时的背景色 */

  color: black !important;

  /* 设置文字颜色 */

}

</style>

css页面:

  1. /* 改变整个输入框的字体颜色背景 */
  2. ::v-deep .el-form-item__label {
  3. color: #FFFFFF;
  4. }
  5. .form-class ::v-deep .el-date-editor {
  6. border: 1px solid #326AFF;
  7. background: #04308D !important;
  8. }
  9. .form-class ::v-deep .el-date-editor.el-input__wrapper {
  10. box-shadow: 0 0 0 0px #326AFF inset;
  11. }
  12. // 输入框
  13. .form-class ::v-deep .el-date-editor .el-range-input{
  14. background: #04308D !important;
  15. font-size: 14px;
  16. font-family: PingFang SC, PingFang SC;
  17. font-weight: 400;
  18. color: #FFFFFF;
  19. }
  20. // 中间的至字
  21. .form-class ::v-deep .el-date-editor .el-range-separator{
  22. background: #04308D !important;
  23. color: #FFFFFF;
  24. }
  25. .form-class ::v-deep .el-range__close-icon{
  26. background: #04308D !important;
  27. color: #FFFFFF;
  28. }
  29. // 输入框
  30. .form-class ::v-deep .el-input__wrapper {
  31. border: 1px solid #326AFF;
  32. box-shadow: 0 0 0 0px #326AFF inset;
  33. background: #04308D !important;
  34. }
  35. // 输入框
  36. ::v-deep .el-input__inner{
  37. background: #04308D !important;
  38. font-size: 14px;
  39. font-weight: 400;
  40. color: #FFFFFF;
  41. }
  42. .blue-button{
  43. background-color: #326aff;
  44. border: 1px solid #326AFF;
  45. }
  46. .el-table{
  47. // 去掉白线
  48. --el-table-border-color:#063570;
  49. }
  50. // 设置表格行高度
  51. ::v-deep .el-table__body tr,
  52. ::v-deep .el-table__body td {
  53. padding: 0;
  54. height: 40px;
  55. }
  56. // 表格内背景颜色
  57. ::v-deep .el-table th,
  58. ::v-deep .el-table tr,
  59. ::v-deep .el-table td {
  60. background-color:#063570;
  61. border: 0px;
  62. color: #fff; // 修改字体颜色
  63. font-size: 24px;
  64. height: 5px;
  65. font-weight: Normal;
  66. }
  67. // 修改表头样式-加边框
  68. ::v-deep .el-table__header-wrapper {
  69. border: solid 1px #00429c;
  70. // box-sizing: border-box;
  71. }
  72. // 修改表头样式-背景色
  73. ::v-deep .el-table__header thead tr th{
  74. border: #002C69 0px solid;
  75. background: linear-gradient(to top, #0085FB, #002C69)!important;
  76. color: #FFFFFF;
  77. }
  78. // 表格斑马自定义颜色
  79. ::v-deep .el-table__row.warning-row1 {
  80. background: #03367c;
  81. border: #002C69 0px solid;
  82. color: #FFFFFF;
  83. }
  84. ::v-deep .el-table__row.warning-row2 {
  85. background: #002C69;
  86. border: #002C69 0px solid;
  87. color: #FFFFFF;
  88. }
  89. .el-table .el-table__body tr:hover {
  90. background-color: #0873fd !important; /* 设置鼠标悬停时的背景色 */
  91. color: black !important; /* 设置文字颜色 */
  92. }
  93. // 滚动条样式
  94. ::v-deep .el-table__body-wrapper::-webkit-scrollbar-track {
  95. background-color: #063570;
  96. }
  97. ::v-deep .el-table__body-wrapper::-webkit-scrollbar {
  98. width: 10px;
  99. opacity: 0.5;
  100. }
  101. ::v-deep .el-table__body-wrapper::-webkit-scrollbar-thumb {
  102. border-radius: 15px;
  103. background-color: #0257aa;
  104. }

 希望对你有帮助

本文内容由网友自发贡献,转载请注明出处:https://www.wpsshop.cn/w/IT小白/article/detail/935968
推荐阅读
相关标签
  

闽ICP备14008679号