chrome浏览器autofill的黄色背景去除

方法1:阴影覆盖
input:-webkit-autofill {
  -webkit-box-shadow: 0 0 0 1000px white inset !important;
}
注:由于是设置颜色覆盖,所以只对非透明的纯色背景有效;

 

方法2:修改chrome浏览器渲染黄色背景的时间(推荐)
:-webkit-autofill {
  -webkit-text-fill-color: #fff !important;
  transition: background-color 5000s ease-in-out 0s;
}
注:此方法适用于上图那种背景为透明色的输入框

 

方法3:jq方式去除

if (navigator.userAgent.toLowerCase().indexOf("chrome") >= 0)
{
  let _interval = window.setInterval(function () {
    let autofills = $('input:-webkit-autofill');
    if (autofills.length > 0) {
      window.clearInterval(_interval); // 停止轮询
      autofills.each(function() {
        let clone = $(this).clone(true, true);
        $(this).after(clone).remove();
      });
    }
  }, 20);
}
https://segmentfault.com/a/1190000013381998?utm_source=channel-hottest
posted @ 2018-02-27 09:45  还记得你的呢喃  阅读(276)  评论(0)    收藏  举报