Posted in site documentation
11515
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
274
This Month
1323
This Year
2912

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
There is a qualitative and quantitative difference between a day that begins with a little exercise, a book, meditation, a good meal, a thoughtful walk, and the start of a day that begins with a smartphone in bed.
Unknown
Random CSS Property

grid-column-end

The grid-column-end CSS property specifies a grid item's end position within the grid column by contributing a line, a span, or nothing (automatic) to its grid placement, thereby specifying the block-end edge of its grid area.
grid-column-end css reference