乐闻世界logo
搜索文章和话题

Removing input background colour for Chrome autocomplete?

1个答案

1

Chrome applies a yellow background to input fields by default when autofilling form content, to notify users that the field is populated by the browser. However, this may conflict with the website's design aesthetic. To modify or remove this background color, we can use the CSS pseudo-class :-webkit-autofill.

Here is a specific CSS example to change the background color after autofill:

css
input:-webkit-autofill, input:-webkit-autofill:hover, input:-webkit-autofill:focus, input:-webkit-autofill:active { -webkit-box-shadow: 0 0 0 30px white inset !important; }

This CSS overrides the default yellow background when the input element is autofilled by a WebKit browser by setting the -webkit-box-shadow property. Here, 0 0 0 30px white inset means adding a white shadow layer inside the input field to cover the original yellow background, and !important ensures higher priority to override browser default styles.

This approach is commonly used in web development to adjust the visual appearance of autofill fields, maintaining the overall aesthetic and consistency of the website interface.

2024年8月14日 13:43 回复

你的答案