删除ios safari/chrome/firefox中点击的链接上的灰色背景

sam*_*sam 65 css mobile-safari ios mobile-chrome

单击(触摸)iOS中的链接(或chrome或firefox)时,链接后面会出现灰色背景(仅在您持有时).有没有办法使用CSS删除此功能?

请参阅下面的示例图片:

在此输入图像描述

pk-*_*-nb 163

Webkit具有特定的样式属性:-webkit-tap-highlight-color.

复制自:http://davidwalsh.name/mobile-highlight-color -

/* light blue at 80% opacity */
html {
    -webkit-tap-highlight-color: rgba(201, 224, 253, 0.8);
}

/* change it for a div that has a similar background-color to the light blue tap color */
.blueDiv {
    -webkit-tap-highlight-color: rgba(251, 185, 250, 0.9);
}
Run Code Online (Sandbox Code Playgroud)

如果你想完全删除高亮 -

.myButton {
    -webkit-tap-highlight-color: rgba(0, 0, 0, 0);
}
Run Code Online (Sandbox Code Playgroud)


小智 10

出于某种原因,最新版本的 iOS 忽略了 RGBA 颜色。

要删除它,我最终不得不使用以下内容:

-webkit-tap-highlight-color: transparent;
Run Code Online (Sandbox Code Playgroud)

如此处所述:https : //developer.mozilla.org/en-US/docs/Web/CSS/-webkit-tap-highlight-color