input选择输入历史后样式改变
发布日期:2021-05-07 19:30:02 浏览次数:25 分类:精选文章

本文共 1339 字,大约阅读时间需要 4 分钟。

一、修改选择背景色

   **chrome表单自动填充后,input文本框的背景会变成偏黄色的,这是由于chrome会默认给自动填充的input表单加上input:-webkit-autofill私有属性,然后对其赋予以下样式:

方式一

input:-webkit-autofill, textarea:-webkit-autofill, select:-webkit-autofill {     background-color: transparent!important;     background-image: none !important;     -webkit-box-shadow: 0 0 0 1000px white inset !important; }

用足够大的纯色阴影去覆盖掉黄色背景

在写实际代码之前做好CSS样式重置可避免一系列稀奇古怪的问题。 

方式二

禁用选择输入历史为input设置autocomplete=“off”当input过多时,可以设置js$(function () {    $("input").attr("autocomplete", "off");});

二、修改选择字体颜色

input:-webkit-autofill {    /* 选择历史记录的文字颜色*/    -webkit-text-fill-color: #666;}

 

若怕出错,将下面的代码复制进去即可:

/* 选择历史记录的文字颜色和背景颜色 */input:-webkit-autofill {    -webkit-animation: autofill-fix 1s infinite!important;    /* 选择历史记录的文字颜色*/    -webkit-text-fill-color: #666;    -webkit-transition: background-color 50000s ease-in-out 0s!important;    transition: background-color 50000s ease-in-out 0s!important;    background-color: transparent!important;    background-image: none !important;    /* 选择历史记录的背景颜色 */    -webkit-box-shadow: 0 0 0 1000px transparent inset!important;}[role=button], a, area, button, input:not([type=range]), label, select, summary, textarea {    -ms-touch-action: manipulation;    touch-action: manipulation;}input[type=number], input[type=password], input[type=text], textarea {    -webkit-appearance: none;}

 

 

上一篇:TypeScript---01简介
下一篇:input file文件上传(enctype)

发表评论

最新留言

路过按个爪印,很不错,赞一个!
[***.219.124.196]2025年04月02日 12时00分15秒