当浏览器自动填充表格时,我想将输入框的背景颜色设置为透明,目前看起来像添加的图片一样,有人知道如何实现吗?
我已经尝试过这个方法,但是它会将背景色设置为白色,并且边框以黄色默认样式呈现,我还希望文本颜色也是白色。
input:-webkit-autofill {
-webkit-box-shadow: 0 0 0px 1000px white inset;
}
这是它的外观:
提前感谢 :)
最终我用这段代码得到了结果:
input:-webkit-autofill,
input:-webkit-autofill:hover,
input:-webkit-autofill:focus,
input:-webkit-autofill:active {
transition: background-color 5000s ease-in-out 0s;
-webkit-text-fill-color: #fff !important;
}
caret-color: #fff;
- Mukhriddin Shakhriyorov使用此功能可节省时间。
input:-webkit-autofill,
input:-webkit-autofill:hover,
input:-webkit-autofill:focus,
input:-webkit-autofill:active {
-webkit-transition-delay: 9999s;
transition-delay: 9999s;
}
感谢martinezjc提供的想法,但如果我们让页面打开一段时间,我们会注意到背景颜色的变化。
我们可以使用CSS动画和forwards填充模式来消除过渡效果,使背景颜色保持不变。
input:-webkit-autofill,
input:-webkit-autofill:hover,
input:-webkit-autofill:focus,
input:-webkit-autofill:active {
-webkit-animation: autofill 0s forwards;
animation: autofill 0s forwards;
}
@keyframes autofill {
100% {
background: transparent;
color: inherit;
}
}
@-webkit-keyframes autofill {
100% {
background: transparent;
color: inherit;
}
}
只需将透明替换为您的颜色。
input:-webkit-autofill,
input:-webkit-autofill:hover,
input:-webkit-autofill:focus,
input:-webkit-autofill:active {
-webkit-animation: autofill 0s forwards;
animation: autofill 0s forwards;
}
@keyframes autofill {
100% {
background: transparent;
color: inherit;
}
}
@-webkit-keyframes autofill {
100% {
background: transparent;
color: inherit;
}
}
完美优秀
-webkit-text-fill-color
是什么?background-color
又是什么?可能重复:https://dev59.com/6HE85IYBdhLWcg3wbS5i - Downgoat