關於input:-webkit-autofill樣式問題

  最近在整理項目的時候,遇到了一個chrome瀏覽器自動填充的樣式問題,javascript

用戶名跟密碼的input都設置爲透明顏色,可是會變成黃色,打開chrome調試工具,發現有個input:-webkit-autofill的 background-color: rgb(250, 255, 189)!important;這個樣式,網上查詢得三種方案,一種是把input自動輸入關閉autocomplete="off",第二種是設置box-shadow陰影覆蓋默認樣式,css

input:-webkit-autofill {
     -webkit-box-shadow: 0 0 0px 1000px white inset;
     -webkit-text-fill-color: #333;
}

  可是這種只適用於純色背景java

  第三種是經過延長增長自動填充背景色的方式, 是用戶感覺不到樣式的變化web

input:-webkit-autofill,
input:-webkit-autofill:hover,
input:-webkit-autofill:focus,
input:-webkit-autofill:active {
     -webkit-transition-delay: 99999s;
     -webkit-transition: color 99999s ease-out, background-color 99999s ease-out;
}

  

  因爲我這裏輸入框是背景爲透明,選擇第二種並無效果,因此選擇第三種。chrome

  總結:網上的方法不少,但要找到適合本身的解決方案。瀏覽器

相關文章
相關標籤/搜索