使用chrome瀏覽器選擇記住密碼的賬號贪薪,輸入框會自動加上黃色的背景,有些設(shè)計輸入框是透明背景的眠副,需要去除掉這個黃色的背景画切;
image.png
方法1:陰影覆蓋
input:-webkit-autofill {
-webkit-box-shadow: 0 0 0 1000px white inset !important;
}
由于是設(shè)置顏色覆蓋,所以只對非透明的純色背景有效囱怕;
方法2:修改chrome瀏覽器渲染黃色背景的時間
:-webkit-autofill {
-webkit-text-fill-color: #fff !important;
transition: background-color 5000s ease-in-out 0s;
}
image.png
注意:不支持input框使用的背景圖片(會被自己設(shè)置的背景顏色覆蓋: white)
可以這樣使用:
原理很簡單霍弹,下面一個 div毫别,上面放 div(顯示圖片) + input,把圖片div放在input的上面典格。
圖片div的css:
.user {background:url("/images/login/icon_user.png");background-repeat:no-repeat; background-position: 5px center;}
.icon-position {z-index:3;position:relative;height:40px;width:28px;}
輸入框的css:
.input-position {margin-top:-40px;padding-left:34px;width:340px;}
.input-style {border:1px solid #dedede;border-radius:4px;font-size:14px;font-family:微軟雅黑,黑體;vertical-align:middle;height:40px;line-height:40px;outline:0px;}
HTML片段:
<div>
<div class="user icon-position"></div>
<input type="text" class="input-position input-style" name="username" id="username" placeholder="登錄賬號">
<div>