我制作了一个如下所示的登录页面:
但是当我在 Firefox 中保存登录数据时,它看起来像这样:
我可以吗?如果可以,我怎样才能摆脱这种黄色色调并制作自己的效果?我发现一些帖子说可以通过使用
-webkit-autofill
伪类来更改它,但这对我不起作用。
代码片段:
button {
border: none;
border-radius: 2px;
box-sizing: border-box;
height: 25px;
margin: 5px;
padding: 0;
outline: none;
background-color: #0060df;
color: rgb(230, 230, 231);
}
.text-input {
height: 25px;
box-sizing: border-box;
border: 1px solid #5a5a5c;
border-radius: 2px;
padding: 0 5px;
margin: 5px;
background-color: #474749 !important;
color: rgb(230, 230, 231) !important;
}
#login-form {
display: flex;
flex-direction: column;
padding: 25px;
border-radius: 2px;
background-color: #323234;
}
<div id="login-form">
<input type="text" class="text-input" id="name-input" placeholder="Name"/>
<input type="password" class="text-input" id="password-input" placeholder="Password"/>
<button id="login-button">Login</button>
</div>
正如您所看到的,添加 !important 也没有帮助(如果可以在代码片段中测试它)。
问候 布莱克
Firefox 自 68 起不支持 :autofill 伪类,您可以订阅 https://bugzilla.mozilla.org/show_bug.cgi?id=740979 来跟踪实现状态。
https://paul.kinlan.me/detecting-when-autofill-happens/描述了一种解决方法,它允许您检测自动填充何时发生并交换新元素来替换现有元素,复制自动填充的数据.
在 Firefox 中,您可以使用 CSS 中的以下内容覆盖黄色
table.login input[type=text],
table.login input[type=password]
{
background: #FFFFFF;
}
表 class="login" 的位置