Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Google Chrome autofill removing background image

When I write in the email box the email, I have no problem and displays perfectly. But when google chrome decides to autofill, the image on the left is removed. http://s9.postimg.org/suz3z56f3/Sem_t_tulo.jpg

I've read some topics about hacking that yellow background, which works, but the image continues to disappear.

input:-webkit-autofill {
    -webkit-box-shadow: 0 0 0 1000px white inset;
}

// html

<input type='email' class='email' placeholder='email'/>

// css

.email{
    background-image: url('http://www.letsgocook.net/sites/default/img/email.png');
    background-repeat: no-repeat;
    padding-left: 35px;
}

http://jsfiddle.net/9AM6X/ > example, but no showing the error because I can't replicate the autofill of chrome in jsfiddle.

like image 531
user3243925 Avatar asked Jan 28 '14 10:01

user3243925


People also ask

How do I remove autofill in Chrome CSS?

Sept 2020: autocomplete="chrome-off" disables Chrome autofill. Original answer, 2015: For new Chrome versions you can just put autocomplete="new-password" in your password field and that's it. I've checked it, works fine.


2 Answers

Puts the image back using keyframes:

@-webkit-keyframes autofill {
    to {
        background-image:url(images/your-input-bg-image.svg);
    }
}

input:-webkit-autofill {
    -webkit-animation-name: autofill;
    -webkit-animation-fill-mode: both;
}

Kudos to @Steve for his answer to Removing input background colour for Chrome autocomplete?

like image 157
wkille Avatar answered Oct 17 '22 04:10

wkille


I'm posting a solution here, essentially as a hack / workaround for the problem described.

Using extra elements we can place the icon on the input element.

Preview: http://output.jsbin.com/necigedago

Working Example:

enter image description here

CSS

.control {
    position: relative;
}

.email {
    padding-left: 35px;
    padding-top: 10px;
    padding-bottom: 10px;
    font-size: 16px;
}

.email ~ .input-icon {
    background-image: url('http://www.letsgocook.net/sites/default/img/email.png');
    background-repeat: no-repeat;
    background-size: 100%;
    background-position: center center;
    width: 22px;
    height: 14px;
    position: absolute;
    left: 8px;
    bottom: 0;
    top: 0;
    margin: auto;
}

HTML

  <p class='control'>
    <input type='email' class='email' placeholder='email'/>
    <span class='input-icon'></span>
  </p>
like image 6
AntonB Avatar answered Oct 17 '22 04:10

AntonB