当我点击 iPhone 上的输入时,是什么原因导致灰色闪烁?

use*_*603 3 html css

使用 iPhone 预览我正在处理的网页时,我注意到每当我单击某个输入时,我都会看到其后面有短暂的灰色闪烁。

我已经删除了所有 CSS,但灰色闪烁仍然存在。它在桌面 Safari 上不可见,仅在移动 Safari 上可见。

是什么原因造成的?我该如何阻止它发生?

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Why do the inputs flash?</title>

  <style type="text/css">
    input {
      display: block;
      width: 100%;
      border-width: 0 0 1px 0;
      border-radius: 0px;
    }
  </style>
</head>
<body>
  <input type="radio" name="mode" id="mode1" value="mode1">
  <label for="mode1">Mode 1</label>

  <input type="radio" name="mode" id="mode2" value="mode2">
  <label for="mode2">Mode 2</label>

  <input type="radio" name="mode" id="mode3" value="mode3">
  <label for="mode3">Mode 3</label>

  <label for="hello">
    <input checked type="checkbox" id="hello">
    <span class="toggle">
      <span class="switch"></span>
    </span>
    <span class="label">Check me</span>
  </label>
  
  <form action="">
    <label for="text-input">
      Enter text
      <input type="text">
    </label>

    <label for="email-iput">
      Enter email here
      <input type="email">
    </label>
  </form>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)

灰色闪烁输入

use*_*603 5

我用谷歌搜索了美式拼写gray,并在 CSS-tricks 上找到了答案

-webkit-tap-highlight-color: rgba(0,0,0,0); 然后允许:active styles在 Mobile Safari 的页面上使用 CSS: document.addEventListener("touchstart", function(){}, true);

编辑

实际上,我只需要-webkit-tap-highlight-color: rgba(0,0,0,0);覆盖灰色闪光即可。