当前位置:   article > 正文

Element-UI 样式修改合集_element ui 表单美化

element ui 表单美化

目录

一、表格 el-table

1、表格表头设置背景色及居中设置

2、表格背景修改为透明

3、表格自带的横线去除

4、表格中行高和字体大小调整

二、表单 el-form

1、修改一个label的样式

三、弹出框 el-popover


一、表格 el-table

1、表格表头设置背景色及居中设置
  1. <template>
  2. <el-table
  3. :header-cell-style="headClass"
  4. :cell-style="rowClass">
  5. </el-table>
  6. </template>
  7. <script>
  8. export default {
  9. methods: {
  10. // 表头样式设置
  11. headClass () {
  12. return 'text-align: center;background:#eef1f6;'
  13. },
  14. // 表格样式设置
  15. rowClass () {
  16. return 'text-align: center;'
  17. }
  18. }
  19. }
  20. </script>
2、表格背景修改为透明
  1. 外部标签 >>> .el-table,
  2. 外部标签 >>> .el-table__expanded-cell {
  3. background-color: transparent !important;
  4. }
  5. 外部标签 >>> .el-table th,
  6. 外部标签 >>> .el-table tr,
  7. 外部标签 >>> .el-table td {
  8. background-color: transparent !important;
  9. }
3、表格自带的横线去除
  1. // 去掉所有的横线
  2. .el-table__row>td{ border: none; }
  3. .el-table::before { height: 0px; }
  4. // 只去除表格的最最底部的横线
  5. div /deep/ .el-table--border::after,
  6. div /deep/ .el-table--group::after,
  7. div /deep/ .el-table::before {
  8. background-color: transparent;
  9. }
4、表格中行高和字体大小调整

(1)行高调整

  1. // 方法一:
  2. element-table的size属性,取值:mini/small/medium
  3. // 方法二:height的最小取值是80px,可以无限增大
  4. :row-style="{height:'80px'}"
  5. // 方法三:
  6. :cell-style="{padding:'0px'}"
  7. // 方法四:设置css以调整表格行高,需要留意如果是scoped,注意使用/deep/
  8. .el-table__row {
  9. line-height: 50px; /* 设置你想要的行高 */
  10. }
  11. // 使用参照:
  12. <el-table
  13. size:mini/small/medium;
  14. :row-style="{height:'20px'}";
  15. :cell-style="{padding:'0px'}";>

(2)字体大小调整

  1. // 方法一:使用行内样式
  2. style="font-size: 10px"
  3. // 方法二:使用css以调整表格字体大小,需要留意如果是scoped,注意使用/deep/
  4. .el-table__cell {
  5. font-size: 16px; /* 设置你想要的字体大小 */
  6. }
  7. // 使用参照:
  8. <el-table style="font-size: 10px">

二、表单 el-form

1、修改一个label的样式

样式修改不要全局,使用/deep/穿透

  1. <el-form>
  2. <el-form-item label="活动区域" class="change-label-calss">
  3. <el-input v-model=""></el-input>
  4. </el-form-item>
  5. </el-form>
  6. <style scoped>
  7. .change-label-calss /deep/ .el-form-item__label{
  8. color: red;
  9. }
  10. </style>

三、弹出框 el-popover

popover的dom创建在了最外层。它是和根组件app同级的dom,所以在任何 <style scoped></style>下写的css均不能生效。如果直接在<style></style>下粗暴修改,势必又会影响到其他组件的样式。

element-ui提供了 popper-class 这个类帮我们设置格式化的css样式以覆盖原有样式。

  1. <template>
  2. <div class="temp">
  3. <el-popover :popper-class="yourClass">
  4. </el-popover>
  5. </div>
  6. </template>
  7. <style scoped>
  8. </style>
  9. <style>
  10. //最外层div,修改背景色,边框
  11. .el-popover.yourClass {
  12. background-color: #090d29;
  13. border-color: #146ebd;
  14. }
  15. //修改title颜色
  16. .yourClass .el-popover__title {
  17. color: white;
  18. }
  19. //修改下面的小三角,属性名根据组件的placement位置做相应修改
  20. .yourClass .popper__arrow::after {
  21. border-top-color: #090d29 !important;
  22. }
  23. </style>

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/一键难忘520/article/detail/935981
推荐阅读
相关标签
  

闽ICP备14008679号