Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Remove the yellow background on input on autofill

Anyone knows how to remove this ugly chrome background when autofill? (Refer below.)

enter image description here

So far I tried:

*:focus {     outline: 0; } input:-webkit-autofill {     -webkit-box-shadow: none;     -webkit-text-fill-color: #fff !important; } button:focus, input:focus, a:focus {     text-decoration: none !important;     outline: none !important; } 

Sadly, none of them works. Any help, ideas, clues, suggestions would be greatly appreciated.

like image 424
Juliver Galleto Avatar asked Mar 18 '15 11:03

Juliver Galleto


People also ask

How do I remove autofill in Chrome CSS?

Autocomplete is disabled with autocomplete="off". AUTOFILL will prompt based on the address book from previously filled out similar forms on other pages. It will also highlight the fields it is changing. Autofill can be disabled with autocomplete="false".

Which property is responsible for setting the background color?

The background-color property sets the background color of an element. The background of an element is the total size of the element, including padding and border (but not the margin). Tip: Use a background color and a text color that makes the text easy to read.


2 Answers

Oddly enough this is the intended behaviour from webkit to let the user infer it was autofilled.

[email protected] We inherit this coloring behavior from WebKit and I believe it's by design. It allows the user to understand the data has been prefilled.

You can use:

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

Which will change the background to white.

You can also turn auto complete off by adding:

autocomplete="off" 

E.g

<input type="text" name="some_name" autocomplete="off"></input> 

To your input, but for usability I would suggest against this.

like image 147
Ryan McDonough Avatar answered Oct 04 '22 04:10

Ryan McDonough


Add this to your header
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 {   border:none !important;   -webkit-text-fill-color: inherit !important;   -webkit-box-shadow: 0 0 0px 1000px #FFFFFF inset;   transition: background-color 5000s ease-in-out 0s; } 

This seems to fix the after-effect of the yellow re-populating on mouseleave

GIF of with and without.

like image 34
Carl Boneri Avatar answered Oct 04 '22 04:10

Carl Boneri