chrome会默认给自动填充的input表单加上input:-webkit-autofill私有属性,然后对其赋予以下样式:
input:-webkit-autofill, textarea:-webkit-autofill, select:-webkit-autofill {
background-color: rgb(250, 255, 189); /* #FAFFBD; */
background-image: none;
color: rgb(0, 0, 0);
}
并且
chrome默认定义的
background-color
,
background-image
,
color
不能用
!important
提升其优先级,为了不影响美观,有以下解决方案,不同情况选择不同方案
方案一(对input:-webkit-autofill使用足够大的纯色内阴影来覆盖input输入框的黄色背景)
- input:-webkit-autofill {
- -webkit-box-shadow: 0 0 0px 1000px white inset;
- border: 1px solid #CCC!important;
- }
autocomplete="off/on"
关闭自动填充表单)
<!-- 对整个表单设置 -->
<form autocomplete="off" method=".." action="..">
<!-- 或对单一元素设置 -->
<input type="text" name="textboxname" autocomplete="off">