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

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

<p>for some reason bootstrap or the browser is doing this to auto filled fields.&nbsp;</p>
<p><img src="https://kruxor.com/images/text%20col%20change.jpg" /></p>
<p>according to my searching there is a pseudo class added to auto filled fields</p>
<h4>CSS</h4>
<pre><code class="css hljs">input:-webkit-autofill {<br /> color: #444!important; <br />}</code></pre>
<p>this option however does not seem to fix it for me.&nbsp;</p>
<p>the option that fixed it is here, apparently changing the focus and adding a shadow to the text fixes it. I <a href="https://stackoverflow.com/questions/2338102/override-browser-form-filling-and-input-highlighting-with-html-css" target="_blank" rel="noopener">found this mentioned here</a>.</p>
<h4>CSS</h4>
<pre><code class="css hljs">input:-webkit-autofill:focus {<br />&nbsp; &nbsp; -webkit-box-shadow: 0 0 0 50px #3b3b3b inset;/your box-shadow/<br />&nbsp; &nbsp; -webkit-text-fill-color: #b1b1b1;<br />}</code></pre>
<p>Working Demo, showing auto fill not going white anymore. so you can actually read the text.&nbsp;</p>
<p><strong><video autoplay="autoplay" loop="loop" controls="controls" width="100%" height="300" data-mce-fragment="1"><source src="https://i.imgur.com/dMJbuCE.mp4" type="video/mp4" /></video></strong></p>
<p><strong>Update here is the css that worked for me</strong></p>
<h4>CSS</h4>
<pre><code class="css hljs"><span class="hljs-selector-tag">input:-webkit-autofill {<br />&nbsp; &nbsp; -webkit-box-shadow:0 0 0 50px white inset;<br />&nbsp; &nbsp; -webkit-text-fill-color: #333;<br />}<br />input:-webkit-autofill:focus {<br />&nbsp; &nbsp; -webkit-box-shadow: 0 0 0 50px #3b3b3b inset;<br />&nbsp; &nbsp; -webkit-text-fill-color: #b1b1b1;<br />}</span></code></pre>

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
341
This Month
1569
This Year
636

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...

You could also follow me on twitter. I have a couple of youtube channels if you want to see some video related content. RuneScape 3, Minecraft and also a coding channel here Web Dev.

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
Don't look to be the next Facebook, try to solve a real problem instead.
Unknown
Latest News
## 🚀 AI Giants Hit Bullseye: Anthropic & OpenAI Achieve Product-Market Fit Anthropic and OpenAI have reached a significant milestone, finding product-market fit with their AI technologies, which means their products effectively meet the needs of their customers, driving growth and adoption. This achievement showcases the practical value of their innovations, enabling businesses and individuals to leverage AI for enhanced productivity and efficiency. With this alignment of product and market needs, these companies are poised to transform industries and shape the future of technology.