【问题标题】:Chrome's autofill hiding text input's background imageChrome的自动填充隐藏文本输入的背景图片
【发布时间】:2016-04-07 05:57:43
【问题描述】:

成功禁用自动填充的淡黄色背景色后, 我偶然发现了另一个功能。

我的每个输入元素都有一个背景图像,每次我关注文本输入时,浏览器都会在下拉列表中建议我之前使用的值。

在我选择一个值后,自动填充会覆盖我的整个背景并隐藏图像。

这是我的 html 和 css(在 JSfiddle 中详细说明):

<section class="formContainer">
    <img class="sesameLogo" src="~/Content/Images/Site/sesamelogo.png" />
    <form id="signUpForm" class="pageForm">
        <input type="text" name="decoy" class="decoy"/>
        <input type="password" name="decoy" class="decoy" />
        <input type="text" placeholder="Full Name" name="FullName" id="fullName" />
        <input type="text" placeholder="Email" name="email" id="email" />
        <input type="password" placeholder="Password" name="password" id="password" />
        <input type="password" placeholder="Confirm Password" name="confirmPassword" id="secPassword" />
        <section id="actionBtnsCont">
            <button id="btnSignUp" class="mainBtn" type="button">Sign Up</button>
            <label class="genContextLbl">or</label>
            <button id="btnSignIn" class="genBtn" type="button">Sign In</button>
        </section>
    </form>
</section>

https://jsfiddle.net/65wkgqs0/

【问题讨论】:

  • 链接只显示一个空白的新项目
  • 我注意到了,已修复。谢谢
  • 不是……我看过那个帖子,它帮助我失去了黄色背景,我的问题是它覆盖了我的背景图片。

标签: html css google-chrome user-agent


【解决方案1】:

你需要的是:

&lt;input&gt;元素移动背景图片

HTML

<div class="email-wrapper">
  <input type="text" placeholder="Email" name="email" id="email" />
</div>

CSS

.email-wrapper {
  display: inline-block;
  background: url(https://www.apec-econ.ca/system/style/images/icon-small-person.png) no-repeat scroll 4px 9px;
}

并在自动填充时推迟更改背景颜色

CSS

input:-webkit-autofill {
  transition: background-color 5000s ease-in-out 0s;
}

更新了你的小提琴:https://jsfiddle.net/65wkgqs0/6/

【讨论】:

  • 谢谢,效果很好!虽然,我希望我能找到除动画或连接两个元素之外的另一种方法..
  • 这对我不起作用。背景图片继续消失。
  • 这似乎把背景图片放在输入后面
猜你喜欢
  • 2013-12-23
  • 2016-11-27
  • 2020-05-10
  • 2018-03-29
  • 1970-01-01
  • 2016-08-31
  • 2015-05-21
  • 2011-08-15
  • 2018-01-24
相关资源
最近更新 更多