html - 自动完成时透明输入字段变为淡黄色

标签 html css

目前我正在创建用于登录和注册的简单表单。样式更改为透明背景,我创建了一个 float 标签。到目前为止一切顺利,一切正常。

enter image description here

当我手动输入一些数据时,标签变小并根据需要移到顶部,背景保持透明。

enter image description here

但是问题来了。虽然自动完成已关闭,但我的浏览器有一个自动完成选项。 如果我选择输入字段的建议,它会以某种方式切换为淡黄色。

enter image description here

有什么想法是从哪里来的,我该如何防止这种情况发生?

感谢您的宝贵时间!

最佳答案

您可以使用以下 CSS 覆盖它:

input,
input:-webkit-autofill,
input:-webkit-autofill:hover,
input:-webkit-autofill:focus {
    background-color: transparent!important;
}

在 Google Chrome 上,您应该执行以下操作:

input,
input:-webkit-autofill,
input:-webkit-autofill:hover,
input:-webkit-autofill:focus {
    -webkit-box-shadow: 0 0 0 30px red inset;
}

有关在 Google Chrome 中删除自动完成颜色的更多信息,请点击此处:Removing input background colour for Chrome autocomplete?

您可以通过将 input 添加到 CSS 规则来避免在选择自动完成值时出现黄色背景。

关于html - 自动完成时透明输入字段变为淡黄色,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46631370/

相关文章:

javascript - 如何在过渡时获得平移偏移量

css - 更改 div 中 Bootstrap 按钮的大小

javascript - 下面的情况如何设置图片的宽度?

javascript - 单击样式化组件更改 css( map 功能)

html - 纯 CSS 响应式翻转框

html - 使用相对定位时将元素的宽度设置为比父元素宽

html - <style> 标签需要 ;是否结束

html - 网页在 Firefox 中看起来不错,但其他所有浏览器都不喜欢它

javascript - 使用 JavaScript 编写拖放代码时出现 "Argument 1 of Node.appendChild is not an object."

javascript - 如何一起使用 element.scrollIntoView 和滚动监听器?