Posted in site documentation
9899
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
284
This Month
979
This Year
1296

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
1. Show your work to the world instead of keeping in your head💆. 2. Do the work consistently👌 3. Respect your work🥰 4. Don't postpone your work 5. Make mistakes 🔥🔥🔥
Unknown
Random CSS Property

inset-inline

The inset-inline CSS property defines the logical start and end offsets of an element in the inline direction, which maps to physical offsets depending on the element's writing mode, directionality, and text orientation. It corresponds to the top and bottom, or right and left properties depending on the values defined for writing-mode, direction, and text-orientation.
inset-inline css reference