【问题标题】:Chrome : user agent stylesheet turn off for transparent backgroundChrome:用户代理样式表为透明背景关闭
【发布时间】:2016-12-15 02:53:04
【问题描述】:

我遇到了一些类似的问题,例如:

Override browser form-filling and input highlighting with HTML/CSSchrome : how to turn off user agent stylesheet settings?

但不幸的是,没有什么能帮助我解决我的问题。

我有一个网页,我将所有输入的背景设置为透明。

在 chrome 中,由于用户代理样式表,它保持黄色背景,我无法将其设置为白色或其他颜色。我也不能从开发设置中关闭,因为用户不会意识到这一点。

我需要一个 css 或 jquery 解决方案。

请帮忙。

更新 - 1

https://jsfiddle.net/hiralvadodaria/8b7a4o23/21/

使用这个 CSS 没有运气:

    input:-webkit-autofill,
textarea:-webkit-autofill,
select:-webkit-autofill {
    -webkit-box-shadow: 0 0 0px 1000px white inset;
    background:none !important;
    background-color: rgb(0,0,0,0) !important;

    background-image: none !important;
    color: rgb(0, 0, 0);
    -webkit-box-shadow:none !important;
    -moz-box-shadow:none !important;
    box-shadow:none !important;
}

这是小提琴。但我无法在那里保存用户名/密码,因此无法显示确切的问题。

改为从我的项目中查找图像。

【问题讨论】:

标签: html css google-chrome


【解决方案1】:
    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 {
  -webkit-text-fill-color: #fff !important;
  -webkit-box-shadow: 0 0 0px 1000px rgba(0, 0, 0, 0) inset !important;
  transition: background-color 5000s ease-in-out 0s !important;
}

试试这个

更新

如果上面的代码由于某种原因对你不起作用,这里是另一个:

@-webkit-keyframes autofill {
        to {
            color: #fff;
            background: transparent;
        }
    }

    input:-webkit-autofill,
    input:-webkit-autofill:hover, 
    input:-webkit-autofill:focus, 
    textarea:-webkit-autofill,
    textarea:-webkit-autofill:hover,
    textarea:-webkit-autofill:focus,
    select:-webkit-autofill,
    select:-webkit-autofill:hover,
    select:-webkit-autofill:focus {
        -webkit-animation-name: autofill;
        -webkit-animation-fill-mode: both;
    }

【讨论】:

  • 谢谢。拯救了我的一天!
  • 干得好,杰伊,但您介意解释一下您的解决方案,以便稍后找到此答案的其他人可以更好地理解吗?
  • @Harald 我从下面的链接找到它:css-tricks.com/snippets/css/…
  • @-webkit-keyframes 自动填充 { to { color: #666;背景:透明; } } 输入:-webkit-autofill { -webkit-animation-name:自动填充; -webkit-animation-fill-mode:两者; }
猜你喜欢
  • 2014-01-14
  • 2013-08-03
  • 1970-01-01
  • 2012-10-08
  • 2017-02-04
  • 2023-03-06
  • 1970-01-01
  • 1970-01-01
  • 2011-11-12
相关资源
最近更新 更多