简体   繁体   English

单击手机浏览器上的图标时显示边框

[英]Showing border when clicking icon on phones browser

I have an icon that you can interact with, basically you click on it and it toggles an visibility class. 我有一个可以与之交互的图标,基本上,您单击它即可切换可见性类。

The problem is when i click/touch it on my phone you can see like a blue marker on top of it. 问题是,当我在手机上单击/触摸它时,您会在其顶部看到一个蓝色标记。 the function etc works, you just get that blue square in the middle of the process, which doesn't look very professionell. 函数等起作用,您只需要在过程的中间看到一个蓝色方块,看起来就不太专业了。 See image below, icon in upper corner, in the middle of the process of it being clicked. 在点击过程的中间,请参见下图,图标在右上角。

在此处输入图片说明

It doesn't happen in any of my computers browsers. 在我的任何计算机浏览器中都没有发生。

And the code looks like this. 代码看起来像这样。 CSS: CSS:

width: 22px;
height: 21px;
position: absolute;
top: 0;
right: 0;
margin: 14px;
cursor: pointer;

HTML: HTML:

<img src="assets/images/heart_empty_icon.png" id="unlike" ng-click="changeLikeIcon()" />

I have added the element to jsfiddle: http://jsfiddle.net/W4Km8/6785/ and tried it on my phone from there, but same result. 我已将元素添加到jsfiddle中: http : //jsfiddle.net/W4Km8/6785/,并从那里在手机上进行了尝试,但结果相同。

Anyone know why this happens and how i can solve it? 任何人都知道为什么会发生这种情况以及我该如何解决?

User selection 用户选择

I think that what happen is the user select the images like you would select text in a desktop browser. 我认为发生的事情是用户选择图像,就像在桌面浏览器中选择文本一样。 Adding user-select: none; 添加user-select: none; to your css with the proper prefixes should work. 到带有适当前缀的css应该起作用。

You can take a look at these links for more informations 您可以查看这些链接以获取更多信息

CSS Tricks articles CSS技巧文章

MDN MDN

Try this 尝试这个

#unlike {
  width: 22px;
  height: 21px;
  position: absolute;
  top: 0;
  left: 0;
  margin: 14px;
  cursor: pointer;
  -webkit-tap-highlight-color: rgba(255, 255, 255, 0); 
  -webkit-tap-highlight-color: transparent; 
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM