每当在Chrome中触摸应用了cursor:pointer 属性的Div时,会出现一个蓝色的高亮显示。
我们如何去掉它?
我已经尝试了以下方法:
-webkit-touch-callout: none;
-webkit-user-select: none;
-khtml-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
但是它们不会影响光标按下时的蓝色高亮显示。
每当在Chrome中触摸应用了cursor:pointer 属性的Div时,会出现一个蓝色的高亮显示。
我们如何去掉它?
我已经尝试了以下方法:
-webkit-touch-callout: none;
-webkit-user-select: none;
-khtml-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
但是它们不会影响光标按下时的蓝色高亮显示。
-webkit-tap-highlight-color: rgba(255, 255, 255, 0);
通过将突出显示颜色设置为透明,解决了这个问题。
来源:http://samcroft.co.uk/2012/alternative-to-webkit-tap-highlight-color-in-phonegap-apps/
据我所知,Vlad K的答案可能会在某些安卓设备上引起问题。更好的解决方案:
-webkit-tap-highlight-color: rgba(0,0,0,0);
-webkit-tap-highlight-color: transparent;
rgba(0,0,0,0)
而不是 rgba(255,255,255,0)
? - Gaurav Aggarwal只需将此添加到您的样式表中,并将 class="no_highlights"
属性添加到要应用此类的元素即可。
.no_highlights{
-webkit-tap-highlight-color: transparent;
-webkit-touch-callout: none;
-webkit-user-select: none;
-khtml-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
}
您也可以为所有元素全局执行此操作,方法是删除类名并执行以下操作。
or you can do this globally for all the elements by removing class name and doing this.
button,
textarea,
input,
select,
a{
-webkit-tap-highlight-color: rgba(0, 0, 0, 0);
-webkit-tap-highlight-color: transparent;
-webkit-user-select: none;
-khtml-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
}
谢谢 :) 但是,蓝色边框作为一种辅助功能存在。虽然它看起来很糟糕,但这对于最需要它的人有所帮助。
根据文档,您可以简单地这样做:
-webkit-tap-highlight-color: transparent; /* for removing the highlight */
在安卓手机上的Chrome 68和Windows上的Chrome 80中,这对我有效。
添加到CSS中
html {
-webkit-tap-highlight-color: transparent;
}
@layer base {
html {
-webkit-tap-highlight-color: transparent;
}
}
-webkit-tap-highlight-color: transparent;
也可以。 - Neil Morgan