Posted in site documentation
9945
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
147
This Month
827
This Year
1342

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
In this case my anchor this week becomes driving almost 2hrs outside of Atlanta to one of my favorite hard core gyms in the world.. MetroFlex aka The Dungeon. The gym owners turn the heat way up so it becomes a fun sweat box and the gym members just watch from afar and leave me alone. I happily drive myself long distances to find MY ANCHOR. Our anchor allows us to have balance, focus and be as productive as possible. And if you're in the middle of a heavy set and your headphones start to fall off your head, like mine did here.. well.. f*ck the headphones. Let em break and fall. You can always get a new pair, but the iron ain't ever gonna lift itself.
Unknown
Random CSS Property

rotateZ()

The rotateZ() CSS function defines a transformation that rotates an element around the z-axis without deforming it. Its result is a <transform-function> data type.
rotateZ() css reference