解决chrome浏览器input背景色偏黄的问题

今天编写登录页面,当在本地查看时在chrome浏览器上input元素的背景色偏黄。之前从来没遇到过,单独给input设置background-color:#fff也不管用,在百度之后知道这是因为chrome浏览器给input加了一个私有属性-webkit-autofill。

input:-webkit-autofill{
    background-color:#faffbd;
    background-image:none;
    color:#000;
} 

因此使用!important对于-webkit-autofill设置的属性是无用的

解决方法给input加足够大的内阴影覆盖原背景色

input:-webkit-autofill{
   -webkit-box-shadow:0 0 0 1000px #fff inset;
}

 

原文地址:https://www.cnblogs.com/zmr2520/p/5284596.html