删除自动填充输入的黄色背景

Remove the yellow background on input on autofill

有人知道如何在自动填充时删除这个丑陋的 chrome 背景吗? (参考下文。)

到目前为止我试过:

*:focus {
    outline: 0;
}
input:-webkit-autofill {
    -webkit-box-shadow: none;
    -webkit-text-fill-color: #fff !important;
}
button:focus, input:focus, a:focus {
    text-decoration: none !important;
    outline: none !important;
}

遗憾的是,其中 none 个有效。任何帮助、想法、线索、建议都将不胜感激。

奇怪的是,这是来自 webkit 的 intended behaviour 让用户推断它是自动填充的。

ben@chromium.org We inherit this coloring behavior from WebKit and I believe it's by design. It allows the user to understand the data has been prefilled.

您可以使用:

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

这会将背景更改为白色。

您还可以通过添加以下内容来关闭自动完成功能:

autocomplete="off"

例如

<input type="text" name="some_name" autocomplete="off"></input>

根据您的意见,但为了可用性,我建议不要这样做。

.form-item-search-block-form input:focus, 
.form-item-search-block-form input:hover, 
.form-item-search-block-form input:active {
    outline: 0 none;
    border: 0 none;
    background: #282828;
    background: url("../images/search_btn.png") no-repeat 96% 9px;
    color: rgb(202,202,202);
}

.form-item-search-block-form input:-webkit-autofill {
    -webkit-box-shadow: 0 0 0 1000px #282828 inset;
    -moz-box-shadow: 0 0 0 1000px #282828 inset;
    box-shadow: 0 0 0 1000px #282828 inset;
    -webkit-transition: all 0.7s ease 0s;
    -moz-transition: all 0.7s ease 0s;
    -o-transition: all 0.7s ease 0s;
    transition: all 0.7s ease 0s;
    -webkit-text-fill-color: #eee !important;
}
将此添加到您的 header
input:-webkit-autofill,
input:-webkit-autofill:hover, 
input:-webkit-autofill:focus
input:-webkit-autofill, 
textarea:-webkit-autofill,
textarea:-webkit-autofill:hover
textarea:-webkit-autofill:focus,
select:-webkit-autofill,
select:-webkit-autofill:hover,
select:-webkit-autofill:focus {
  border:none !important;
  -webkit-text-fill-color: inherit !important;
  -webkit-box-shadow: 0 0 0px 1000px #FFFFFF inset;
  transition: background-color 5000s ease-in-out 0s;
}

这似乎修复了 mouseleave

上黄色 re-populating 的 after-effect