#-webkit-autofill##google#启用表单自动填充时,如何覆盖黄色背景

google和opera浏览器的表单自动填充后,输入框均会变成黄色背景,黑色字体。如下图。

autofill

这样的话会与网页的整体设计风格不一致,怎样自定义样式,来覆盖黄色背景。

首先来看看是什么导致的,右键查看元素样式:

input:-webkit-autofill,textarea:-webkit-autofill, select:-webkit-autofill{
  background-color: rgb(250, 255, 189);
  background-image: none;
  color: rgb(0, 0, 0);
}
一目了然了,-webkit-autofill重新渲染了input的背景色及字体颜色。
 
ok,原因找到了,解决方法也有了,重写-webkit-autofill
1, Not working
input:-webkit-autofill,textarea:-webkit-autofill, select:-webkit-autofill{
  rgb(255, 255, 255);
  background-image: none;
  color: rgb(102, 102, 102);
}
2,  Not working
input:-webkit-autofill,textarea:-webkit-autofill, select:-webkit-autofill{
  rgb(255, 255, 255) !important;
  background-image: none !important;
  color: rgb(102, 102, 102) !important;
}
3, working
input:-webkit-autofill,textarea:-webkit-autofill, select:-webkit-autofill{
  -webkit-box-shadow:0 0 0 50px white inset; /* Change the color to your own background color */
  -webkit-text-fill-color: #666;
}
 
ok 表单的黄色填充颜色没有了,
autofill ok

posted on   加油_linda  阅读(977)  评论(0编辑  收藏  举报

编辑推荐:
· 10年+ .NET Coder 心语,封装的思维:从隐藏、稳定开始理解其本质意义
· .NET Core 中如何实现缓存的预热?
· 从 HTTP 原因短语缺失研究 HTTP/2 和 HTTP/3 的设计差异
· AI与.NET技术实操系列:向量存储与相似性搜索在 .NET 中的实现
· 基于Microsoft.Extensions.AI核心库实现RAG应用
阅读排行:
· TypeScript + Deepseek 打造卜卦网站:技术与玄学的结合
· 阿里巴巴 QwQ-32B真的超越了 DeepSeek R-1吗?
· 【译】Visual Studio 中新的强大生产力特性
· 10年+ .NET Coder 心语 ── 封装的思维:从隐藏、稳定开始理解其本质意义
· 【设计模式】告别冗长if-else语句:使用策略模式优化代码结构
< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5

统计

点击右上角即可分享
微信分享提示