修改antdv3组件默认样式

1.修改antdv3组件默认样式

方法一:在组件外写一个div,修改这个div下组件的样式就不会更改全局的样式了;

方法二:style标签添加scoped,给每个样式加上::v-deep();

方法三:如果方法一和方法二不生效,只能使出秘密武器。设置组件的getContainer属性(有的组件是getPopupContainer),我们将原本渲染在#app外部的节点,手动挂载到了#app内部,之后再通过第二条的规则去设置就可以啦~

比如,修改modal的header部分的背景颜色,试了方法一和方法二都不生效。需要使用方法三,先通过挂载元素,再css穿透::v-deep(.ant-modal-body){} 修改样式。

//:getContainer="() => $refs.globalModal"


::v-deep(.ant-modal-header){
  background: rgb(24, 27, 34) ;
  border-bottom: 1px solid rgb(54, 61, 77);
}
2.修改antdv3鼠标悬浮表格某一行改变颜色
.ant-table-tbody > tr:hover:not(.ant-table-expanded-row) > td,
  .ant-table-row-hover,
  .ant-table-row-hover > td {
    background-color: rgb(37, 45, 59) !important;
    color: #ffffff;
  }

  .ant-table-fixed .ant-table-row-hover,
  .ant-table-row-hover > td {
    background-color: rgb(37, 45, 59) !important;
    color: #ffffff;
  }
3. 修改antdv3分页下拉框默认样式
.ant-pagination.mini .ant-pagination-options-quick-jumper {
    color: #ffffff;
    input {
      background-color: rgb(31, 36, 44);
      color: #ffffff;
    }
  }
  .ant-pagination.mini .ant-pagination-item,
  .ant-pagination.mini .ant-pagination-prev,
  .ant-pagination.mini .ant-pagination-next {
    background-color: rgb(31, 36, 44) !important;
    color: #ffffff !important;
  }
  .ant-pagination.mini .ant-pagination-item-active a {
    color: #ffffff !important;
    background-color: #1890ff !important;
  }
  .ant-pagination.mini .ant-pagination-total-text {
    color: #ffffff;
  }
  .ant-pagination.mini .ant-pagination-item a {
    color: #ffffff;
  }
  .ant-select-dropdown {
    background-color: rgb(46, 51, 59) !important;
    color: #ffffff !important;
  }
  .ant-select-arrow {
    color: #fff;
  }

  .ant-select-selector {
    height: 24px;
    border-radius: 4px;
    background-color: transparent;
  }

  .ant-select-dropdown {
    background-color: transparent;

    .ant-select-item {
      color: #fff;

      &:hover {
        background-color: rgb(31, 36, 44);
      }
    }

    .ant-select-item-option-active {
      background-color: rgb(46, 51, 59);
    }

    .ant-select-item-option-selected {
      background-color: rgb(46, 51, 59);
    }
  }
  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值