Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Removing input background colour for Chrome autocomplete?

On a form I'm working on, Chrome is auto-filling the email and password fields. This is fine, however, Chrome changes the background colour to a pale yellow colour.

The design I'm working on is using light text on a dark background, so this really messes up the look of the form - I have stark yellow boxes and near-invisible white text. Once the field is focused, the fields return to normal.

Is it possible to stop Chrome changing the colour of these fields?

like image 715
DisgruntledGoat Avatar asked May 06 '10 13:05

DisgruntledGoat


People also ask

How can I set text background color in HTML?

To add background color in HTML, use the CSS background-color property. Set it to the color name or code you want and place it inside a style attribute. Then add this style attribute to an HTML element, like a table, heading, div, or span tag.


2 Answers

You can change input box styles as well as text styles inside input box:

Here you can use any color e.g. white, #DDD, rgba(102, 163, 177, 0.45).

But transparent won't work here.

/* Change the white to any color */ input:-webkit-autofill, input:-webkit-autofill:hover,  input:-webkit-autofill:focus,  input:-webkit-autofill:active{     -webkit-box-shadow: 0 0 0 30px white inset !important; } 

Additionally, you can use this to change the text color:

/*Change text in autofill textbox*/ input:-webkit-autofill{     -webkit-text-fill-color: yellow !important; } 

Advice: Don't use an excessive blur radius in the hundreds or thousands. This has no benefit and might put processor load on weaker mobile devices. (Also true for actual, outside shadows). For a normal input box of 20px height, 30px ‘blur radius’ will perfectly cover it.

like image 90
Fareed Alnamrouti Avatar answered Sep 18 '22 10:09

Fareed Alnamrouti


I have a better solution.

Setting the background to another color like below didn't solve the problem for me because I needed a transparent input field

-webkit-box-shadow: 0 0 0px 1000px white inset; 

So I tried some other things and I came up with this:

input:-webkit-autofill, input:-webkit-autofill:hover, input:-webkit-autofill:focus, input:-webkit-autofill:active {     transition: background-color 5000s ease-in-out 0s; } 
like image 32
Nathan White Avatar answered Sep 19 '22 10:09

Nathan White