remove grey background on link clicked in ios safari / chrome / firefox
当您在 iOS 的 Safari(或 chrome 或 firefox)中单击(触摸)链接时,链接后面会出现灰色背景(仅当您按住它时)。有没有办法使用 CSS 删除此功能?
请看下面的示例图片:
Webkit 有一个特定的样式属性:
复制自:http://davidwalsh.name/mobile-highlight-colora€"
1 2 3 4 5 6 7 8 9 | /* 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); } |
如果你想完全去除高光a€"
1 2 3 | .myButton { -webkit-tap-highlight-color: rgba(0, 0, 0, 0); } |
最新版本的 iOS 出于某种原因忽略了 RGBA 颜色。
要删除它,我最终不得不使用以下内容:
1 | -webkit-tap-highlight-color: transparent; |
如此处所述:
https://developer.mozilla.org/en-US/docs/Web/CSS/-webkit-tap-highlight-color