It’s been a long while since I’ve dealt with this, and today it seems there are a few quirks across browsers. How do you remove all the styles when you are selecting an autocomplete result from an <input type="email" />
?
In Safari it looks like this (note: I don’t have any yellow or green styles in my app):
In Chrome it looks like this (has blue and uses a font I don’t have specified in my CSS, notice how the text is small and unstyled before fully selecting it):
How do I control all these styles? I would like for it to just be white in all cases for now (background white), and the text to be the same style in all states (placeholder is slightly lighter gray text, but that’s it).
I tried styling input:focus::placeholder {}
but that doesn’t seem to do anything related to these things that are happening. I tried input:active
which is what I would think is the state when selecting an autocomplete value, but no go. Any ideas?
Here is my complete input if that makes a difference:
<input id="email" name="email" type="email" required="" autocapitalize="off" autocorrect="off" placeholder="Your best email" style="min-width: 100%;" data-gtm-form-interact-field-id="0">
I don’t know where data-gtm-form-interact-field-id
is coming from, that is what I get when copying outerHTML from the web inspector.
Update
As per @Qyriad’s :autofill
suggesion, I got this far:
input:-internal-autofill-selected {
appearance: menulist-button;
background-image: none !important;
background-color: var(--color-base-background) !important;
color: fieldtext !important;
}
input:-webkit-autofill::first-line {
background: var(--color-base-background);
font-family: 'Noto Sans Mono';
font-size: 16px;
}
input:auto-fill {
background: var(--color-base-background);
font-family: 'Noto Sans Mono';
font-size: 16px;
}
input:-webkit-autofill {
background: var(--color-base-background);
font-family: 'Noto Sans Mono';
font-size: 16px;
}
But still the font style isn’t working… Appears to be a bug.
2
Answers
I think you are looking for the
:autofill
CSS pseudo-class.