I have a login form with username and password inputs. In Chrome on Windows (doesn\'t happen in other browsers or on a Mac), when hovering over a saved username from the Chr
This seems to be a recent change in Chrome: Issue 953689: Previously entered form values overrides styling when moused over. As far as I’ve seen this happens both on macOS and Windows, anywhere autofill is presented to the end user. Apparently this has intentionally been done to fix a security issue with the previous implementation – Issue 916838: Security: Two autocomplete flaws together allow sites to invisibly read credit card numbers after a single keypress
There doesn’t seem to be a way to override those new styles at the moment – if the change in styles is really too obnoxious, you can either disable autofill (Disabling Chrome Autofill) or set your field’s font styles (font-family
, font-weight
, font-style
, font-size
to match that of Chrome’s autofill suggestions – as suggested here: https://stackoverflow.com/a/56997845/1798491)
How to change Chrome autocomplete styles on input:
input {
...
font-family: $body-font;
font-size: 1rem;
font-weight: bold;
color: #000;
background-color: #fff;
// Background color
&:-webkit-autofill {
-webkit-box-shadow: 0 0 0 1000px #fff inset;
}
// Font styles
&:-webkit-autofill::first-line {
font-family: $body-font;
font-size: 1rem;
font-weight: bold;
// color: green;
}
}
I don't run on windows but have you tried targeting the label and form as well? Re: css specificity. Then try web-kit auto-fills on all
As of now it seems that there's no way to change this in Chrome. I'd definitely call it a bug.
However, a decent workaround is to set the font-family
for all autofill-able inputs or inputs within forms that have autofill abilities to this:
font-family: -apple-system, system-ui, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Ubuntu, Arial, sans-serif;
This is a great cross-browser, cross-platform solution because it just takes whatever your system font is, which is exactly what Chrome seems to be doing for it's autofill font.
It also ensures that your forms are going to have readable fonts on whatever OS your user is using.
try this!
&:-webkit-autofill::first-line,
&:-webkit-autofill,
&:-webkit-autofill:hover,
&:-webkit-autofill:focus,
&:-webkit-autofill:active {
font-family: Times, "Times New Roman", serif !important;
}
you might only need this though
&:-webkit-autofill::first-line
the others are just incase