Posted in site documentation
12009
12:11 am, June 17, 2021
 

for auto filled fields, need to change the text and background colours

for some reason bootstrap or the browser is doing this to auto filled fields. 

according to my searching there is a pseudo class added to auto filled fields

CSS

input:-webkit-autofill {
color: #444!important;
}

this option however does not seem to fix it for me. 

the option that fixed it is here, apparently changing the focus and adding a shadow to the text fixes it. I found this mentioned here.

CSS

input:-webkit-autofill:focus {
    -webkit-box-shadow: 0 0 0 50px #3b3b3b inset;/*your box-shadow*/
    -webkit-text-fill-color: #b1b1b1;
}

Working Demo, showing auto fill not going white anymore. so you can actually read the text. 

Update here is the css that worked for me

CSS

input:-webkit-autofill {
    -webkit-box-shadow:0 0 0 50px white inset;
    -webkit-text-fill-color: #333;
}
input:-webkit-autofill:focus {
    -webkit-box-shadow: 0 0 0 50px #3b3b3b inset;
    -webkit-text-fill-color: #b1b1b1;
}

CSS

/* Not Working #1 */
@media (prefers-color-scheme: dark) {
     input:-webkit-autofill {
        color: #b1b1b1!important;
        background-color: #3b3b3b!important;
    }
}

/* Not Working #2 */
input:-webkit-autofill {
  color: #444!important; 
}

/* This one seems to work, but the background is still white and dark text, but at least you can read the fields */
input:-webkit-autofill {
    -webkit-box-shadow:0 0 0 50px white inset;
    -webkit-text-fill-color: #333;
}
input:-webkit-autofill:focus {
    -webkit-box-shadow: 0 0 0 50px #3b3b3b inset;
    -webkit-text-fill-color: #b1b1b1;
}

View Statistics
This Week
311
This Month
1663
This Year
3406

No Items Found.

Add Comment
Type in a Nick Name here
 
Related Search Terms
Search Code
Search Code by entering your search text above.
Welcome

This is my test area for webdev. I keep a collection of code here, mostly for my reference. Also if i find a good link, i usually add it here and then forget about it. more...

Subscribe to weekly updates about things i have added to the site or thought interesting during the last week.

You could also follow me on twitter or not... does anyone even use twitter anymore?

If you found something useful or like my work, you can buy me a coffee here. Mmm Coffee. ☕

❤️👩‍💻🎮

🪦 2000 - 16 Oct 2022 - Boots
Random Quote
therock Somewhere along this crazy road I learned (often times the hard way) the most important things I can do is be authentic, trust my gut, be the hardest worker in the room, celebrate the mistakes, be a grateful man and always remember that it's nice to be important, but it's more important to be nice.
The Rock
Random CSS Property

border-style

The border-style shorthand CSS property sets the line style for all four sides of an element's border.
border-style css reference