Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to change Safari autofill yellow background color

This image is what I get from safari:

This is what I get from Safari

While this is my code:

This is from my style sheet

Sources:

How to Remove WebKit's Banana-Yellow Autofill Background

Remove forced yellow input background in Chrome - even it says chrome but still pointing to webkit-autofill

I had tried to use background-color:white !important; to override the locked css. Debug tool showed User Agent Stylesheet background-color had crossed out, but still the color didn't change and the custom was in used.

That's what really confused me, I have no idea why aren't allow to change the User Agent Stylesheet.

like image 878
roger Avatar asked Nov 29 '22 00:11

roger


1 Answers

What I found out is that those solutions including -webkit-box-shadow and background-color work only in Google Chrome browser, but not in Safari. What works for me is adding background-clip: content-box. In the end, the code (working in all browsers) looks like:

input:-webkit-autofill,
input:-webkit-autofill:hover,
input:-webkit-autofill:focus,
input:-webkit-autofill:active  {
    -webkit-box-shadow: 0 0 0 60px #fafafa inset !important;
    background-color: #fafafa !important;
    background-clip: content-box !important;
}
like image 53
Petr Tichý Avatar answered Dec 09 '22 20:12

Petr Tichý