首页 > 解决方案 > 是否有支持的 -webkit-tap-highlight-color: transparent 版本?

问题描述

当我在移动设备中按下圆形按钮时,会出现蓝色的突出显示颜色,但在其他设备中,突出显示不会出现。

在移动布局中,按下按钮时:

![在此处输入图像描述

为了消除移动设备中的突出显示,我使用了-webkit-tap-highlight-color解决问题的 CSS 样式,但不推荐使用该样式,如MDN 文档中所述。

是否有支持的版本来解决这个问题?

使用的 CSS:

button {
  height: 60px;
  width: 60px;
  border: none;
  padding: 10px;
  background-color: #212121;
  color: #fafafa;
  border-radius: 50%;
  font-size: 1.5em;

  /* Remove the highlight on button press */
  -webkit-tap-highlight-color: transparent;
  -webkit-tap-highlight-color: rgba(0, 0, 0, 0);
}

button:hover {
  cursor: pointer;
  background-color: #343434;
}

/* Button click effect */
button:active {
  font-size: 1.3em;
}

标签: css

解决方案


推荐阅读