反正点击快速防止Chrome中的元素的蓝色突出显示? [英] Anyway to prevent the Blue highlighting of elements in Chrome when clicking quickly?

查看:95
本文介绍了反正点击快速防止Chrome中的元素的蓝色突出显示?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大多数时候,我不担心它,但我有一个图像旋转木马,如果我点击下一个和以前的divs快速,他们将在Chrome中突出显示。

Most of the time I'm not worried about it but I have an image carousel and if I click on the next and previous divs quickly, they will be highlighted in Chrome.

我试过使用outline:none但没有效果。

I tried using outline:none but no effect. Are there any solutions out there?

推荐答案

除了链接由Floremin提供,它清除文本选择使用JavaScript清除选择,你也可以使用纯CSS来完成这个。 CSS在这里...

In addition to the link provided by Floremin, which clears text selection using JavaScript to "clear" the selection, you can also use pure CSS to accomplish this. The CSS is here...

.noSelect {
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    -khtml-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
}

只需添加 class =noSelect code>属性到你想要应用这个类的元素。我强烈推荐给这个CSS解决方案。使用JavaScript没有什么问题,我只是相信这可能会更容易,并在你的代码清理一点。

Simply add the class="noSelect" attribute to the element you wish to apply this class to. I would highly recommend giving this CSS solution a try. Nothing wrong with using the JavaScript, I just believe this could potentially be easier, and clean things up a little bit in your code.

-webkit -tap-highlight-color:rgba(255,255,255,0); 是您可以尝试的附加规则。

-webkit-tap-highlight-color: rgba(255, 255, 255, 0); is an additional rule you may want to experiment with.

这篇关于反正点击快速防止Chrome中的元素的蓝色突出显示?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆