HTML/input:修订间差异

来自康健生活
Kangkk​(留言 | 贡献)
创建页面,内容为“== 引言 == == 自动填充 == input 自动填充时背景色的颜色变更: <syntaxhighlight lang="css"> // input 输入框,自动填充颜色问题 .ant-inpu…”
 
Kangkk​(留言 | 贡献)
 
第1行: 第1行:
== 引言 ==
== 引言 ==
== 方法 ==
=== oninput ===
<syntaxhighlight lang="html5">
<input type="number" oninput="(e) => {
  let value = e?.target?.value || '';
  if (!(/^[0-9]+$/).test(value)) value = value.replace(/\D/g, '');
  if(value > 100) value = 100;
  if(value < 0) value = null;
  e.target.value = value;
}" /></syntaxhighlight>
== 自动填充 ==
== 自动填充 ==
input 自动填充时背景色的颜色变更:
input 自动填充时背景色的颜色变更:

2022年7月10日 (日) 14:20的最新版本

引言

方法

oninput

<input type="number" oninput="(e) => {
  let value = e?.target?.value || '';
  if (!(/^[0-9]+$/).test(value)) value = value.replace(/\D/g, '');
  if(value > 100) value = 100;
  if(value < 0) value = null;
  e.target.value = value;
}" />

自动填充

input 自动填充时背景色的颜色变更:

// input 输入框,自动填充颜色问题
.ant-input:-webkit-autofill,
.ant-input:-webkit-autofill:hover,
.ant-input:-webkit-autofill:focus,
.ant-input:-webkit-autofill:active {
    -webkit-transition-delay: 111111s;
    -webkit-transition: color 11111s ease-out, background-color 111111s ease-out;
    box-shadow: 0 0 0px 1000px #131417 inset !important;
}