
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;}
发表评论
最新留言
路过按个爪印,很不错,赞一个!
[***.219.124.196]2025年04月02日 12时00分15秒
关于作者

喝酒易醉,品茶养心,人生如梦,品茶悟道,何以解忧?唯有杜康!
-- 愿君每日到此一游!
推荐文章
云原生2.0时代下,DevOps实践如何才能更加高效敏捷?
2021-05-09
技巧收藏|10个JavaScript常用数组操作方法
2021-05-09
两种端到端通用目标检测方法
2021-05-09
云小课 | 守护网络安全不是问题,iptables的四表五链为你开启“八卦阵”
2021-05-09
LiteOS内核源码分析:任务栈信息
2021-05-09
23种设计模式之迭代器模式
2021-05-09
23种设计模式之组合模式
2021-05-09
mysql zip安装
2021-05-09
mysql修改密码
2021-05-09
virtualbox中 Kali Linux安装增强功能
2021-05-09
virtualbox中 Ubuntu挂载共享文件夹
2021-05-09
Python 内置函数笔记
2021-05-09
BootStrapTable 错误
2021-05-09
PHP 脚本不报错
2021-05-09
代码整洁之道小结
2021-05-09
悲观锁与乐观锁
2021-05-09
js new Date 创建时间默认是8点
2021-05-09
Python实现cmd命令连续执行
2021-05-09
罗马数字
2021-05-09
IO多路复用小故事
2021-05-09