Tam*_*Pap 190
用一个"强大的"内部阴影欺骗它:
input:-webkit-autofill {
-webkit-box-shadow:0 0 0 50px white inset; /* Change the color to your own background color */
-webkit-text-fill-color: #333;
}
input:-webkit-autofill:focus {
-webkit-box-shadow: 0 0 0 50px white inset;/*your box-shadow*/
-webkit-text-fill-color: #333;
}
Run Code Online (Sandbox Code Playgroud)
Phi*_*off 148
对于自动完成,您可以使用:
<form autocomplete="off">
Run Code Online (Sandbox Code Playgroud)
关于着色问题:
从您的屏幕截图我可以看到webkit生成以下样式:
input:-webkit-autofill {
background-color: #FAFFBD !important;
}
Run Code Online (Sandbox Code Playgroud)
1)由于#id-styles比.class样式更重要,以下内容可能有效:
#inputId:-webkit-autofill {
background-color: white !important;
}
Run Code Online (Sandbox Code Playgroud)
2)如果这不起作用,你可以尝试通过javascript编程设置样式
$("input[type='text']").bind('focus', function() {
$(this).css('background-color', 'white');
});
Run Code Online (Sandbox Code Playgroud)
3)如果这不起作用,你注定要失败:-)考虑一下:这不会隐藏黄色,但会使文本再次可读.
input:-webkit-autofill {
color: #2a2a2a !important;
}
Run Code Online (Sandbox Code Playgroud)
4)css/javascript解决方案:
CSS:
input:focus {
background-position: 0 0;
}
Run Code Online (Sandbox Code Playgroud)
以下javascript必须运行onload:
function loadPage()
{
if (document.login)//if the form login exists, focus:
{
document.login.name.focus();//the username input
document.login.pass.focus();//the password input
document.login.login.focus();//the login button (submitbutton)
}
}
Run Code Online (Sandbox Code Playgroud)
例如:
<body onload="loadPage();">
Run Code Online (Sandbox Code Playgroud)
祝好运 :-)
5)如果以上工作都没有尝试删除输入元素,克隆它们,然后将克隆的元素放回页面(适用于Safari 6.0.3):
<script>
function loadPage(){
var e = document.getElementById('id_email');
var ep = e.parentNode;
ep.removeChild(e);
var e2 = e.cloneNode();
ep.appendChild(e2);
var p = document.getElementById('id_password');
var pp = p.parentNode;
pp.removeChild(p);
var p2 = p.cloneNode();
pp.appendChild(p2);
}
document.body.onload = loadPage;
</script>
Run Code Online (Sandbox Code Playgroud)
6)从这里:
if (navigator.userAgent.toLowerCase().indexOf("chrome") >= 0) {
$(window).load(function(){
$('input:-webkit-autofill').each(function(){
var text = $(this).val();
var name = $(this).attr('name');
$(this).after(this.outerHTML).remove();
$('input[name=' + name + ']').val(text);
});
});
}
Run Code Online (Sandbox Code Playgroud)
小智 23
添加此CSS规则,黄色背景颜色将消失.:)
input:-webkit-autofill {
-webkit-box-shadow: 0 0 0px 1000px white inset;
}
Run Code Online (Sandbox Code Playgroud)
Jas*_*ter 13
<form autocomplete="off">
Run Code Online (Sandbox Code Playgroud)
几乎所有现代浏览器都会尊重这一点.
don*_*don 13
经过2个小时的搜索,似乎Google Chrome仍然以某种方式覆盖了黄色,但我找到了修复程序.它也适用于悬停,焦点等.您所要做的就是添加!important它.
input:-webkit-autofill,
input:-webkit-autofill:hover,
input:-webkit-autofill:focus,
input:-webkit-autofill:active {
-webkit-box-shadow: 0 0 0px 1000px white inset !important;
}
Run Code Online (Sandbox Code Playgroud)
这将完全从输入字段中删除黄色
Ker*_*777 11
这似乎对我有用:
input {
-webkit-background-clip: text !important;
}Run Code Online (Sandbox Code Playgroud)