Chrome浏览器记住密码后input框黄色背景且背景图片不显示的问题

Chrome浏览器记住密码后再进入登陆页后,输入框背景颜色变为黄色,字体颜色变成#000黑色,且添加的背景图片也那不显示了,进入审查元素后,发现浏览器默认给输入框添加了样式,而且没法经过important修改html

input:-webkit-autofill, textarea:-webkit-autofill, select:-webkit-autofill {
    background-color: rgb(250, 255, 189);
    background-image: none;
    color: rgb(0, 0, 0);
}

 解决方法:web

1.若是没有设置背景图片-经过白色阴影覆盖黄色,并设置字体颜色浏览器

input:-webkit-autofill {
    -webkit-box-shadow: 0 0 0px 1000px #fff inset !important;/*白色*/
     -webkit-text-fill-color: #323333;/*字体颜色*/
}

或经过延迟自动填充的时间字体

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;
    }

 

2.有背景图片spa

第一种:经过autocomplete="off"关闭浏览器自带填充表单功能code

第二种:背景图片不写在input里,利用absolute置于input框上htm

<div class="inputWrap">
    <span class="userLabel"></span>
    <input placeholder="用户名" type="text" id="username" name="username">
</div>
相关文章
相关标签/搜索