Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Change font color of autofill input field

Tags:

I've managed to change the background color of an autofilled input field from yellow to white with the following code:

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

However, changing the font color to grey simply by adding color: #999; doesn't work. How could I fix this? Many thanks!

like image 360
TheLeonKing Avatar asked Mar 25 '14 10:03

TheLeonKing


People also ask

How do you change the font color for disabled input?

Approach: With adding basic CSS property we are able to change the font-color of a disabled input. The disabled input element is unusable and un-clickable. This is a boolean attribute. Here using the color property of input we can change the font-color of this disabled input element.

How do you change the font color in a script?

Users can change the style of the element using the . style property. Also, we can change the specific style, such as element color, background color, size, etc. In our case, we will change the color attribute values to change the font color.

How do you fill text with 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

Try the below CSS

input:-webkit-autofill {     -webkit-box-shadow:0 0 0 50px white inset; /* Change the color to your own background color */     -webkit-text-fill-color: #999; } input:-webkit-autofill:focus {     -webkit-box-shadow: /*your box-shadow*/,0 0 0 50px white inset;     -webkit-text-fill-color: #999; } 
like image 100
Kawinesh SK Avatar answered Nov 10 '22 09:11

Kawinesh SK


Try the below CSS:

/* Change Autocomplete styles in Chrome*/ 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: 1px solid green;   -webkit-text-fill-color: green;   -webkit-box-shadow: 0 0 0px 1000px #000 inset;   transition: background-color 5000s ease-in-out 0s; } 

We can use the -webkit-autofill pseudo-selector to target those fields and style them as we see fit.

like image 29
Mahdi Afzal Avatar answered Nov 10 '22 11:11

Mahdi Afzal