Style Autofill or Autocomplete Default Browser Dropdown

不羁的心 提交于 2019-12-01 08:17:27

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: system-ui, -apple-system, 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.

Brice

I had this identical question, unfortunately everything I've seen says that this can't be done in any sort of "native" way. The primary suggestion that most give is setting auto-complete to off and then building & styling your own, which in most instances is probably more work then it's worth.

I can't find a way to make it work corectly. It's definitely a bug in Chrome.

The best workaround I came up with is to add this css to all of your inputs that might be autofilled:

font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Ubuntu, Arial, sans-serif;

This will take your system font, no matter what system you are using, and apply it to the input. This is what Chrome is doing as well so the font won't change when you hover autofill options.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!