Ant Design of Vue中修改a-input默认样式

文章介绍了在AntDesignofVue中如何修改input组件的默认样式,特别是处理浏览器的自动填充功能导致的样式冲突问题。通过使用特定的CSS选择器和延迟过渡效果,确保自定义样式生效。同时,文章还提到了输入框错误状态下的背景颜色设置以及调整input与边框的间距方法。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

Ant Design of Vue中修改a-input默认样式

浏览器对于input会有自动填充功能,给input添加默认样式,导致自定义样式不生效,书写以下样式进行延迟使自定义样式生效

input:-webkit-autofill,
input:-webkit-autofill:hover,
input:-webkit-autofill:focus,
input:-webkit-autofill:active
{ 
        -webkit-transition-delay: 99999s; 
        -webkit-transition: color 99999s ease-out, background-color 99999s ease-out; 
        transition-delay: 99999s; 
        transition: color 99999s ease-out, background-color 99999s ease-out;
}

修改默认样式

.has-error .ant-input-affix-wrapper .ant-input, .has-error .ant-input-affix-wrapper .ant-input:hover {
    background: #141C68;
  } // 错误时的背景颜色

  .has-error .ant-input, .has-error .ant-input:hover {
    background: #141C68;
  } // 错误时的背景颜色
  
  .ant-input-affix-wrapper .ant-input:not(:first-child) {
    padding-left: 46px;
  } // input与边框之间的距离

参考文档:https://blog.youkuaiyun.com/RepecTT/article/details/125784577#comments_27574635

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值