简体   繁体   English

-webkit-tap-highlight-color: rgba(0,0,0,0); 在 div 上?

[英]-webkit-tap-highlight-color: rgba(0,0,0,0); on a div?

有什么方法可以将其应用于 div 吗?

Are you writing for iPhone/Smartphone websites?你在为 iPhone/智能手机网站写作吗? If so, then yes.如果是这样,那么是的。 But you'll probably only see the results on your phone/simulator.但您可能只会在手机/模拟器上看到结果。 I think that this element can only be used on links or javascript elements.我认为这个元素只能用于链接或 javascript 元素。 The div would have to be affected by some kind of scripting, or be a link. div 必须受到某种脚本的影响,或者是一个链接。

https://developer.apple.com/library/content/documentation/AppleApplications/Reference/SafariWebContent/AdjustingtheTextSize/AdjustingtheTextSize.html https://developer.apple.com/library/content/documentation/AppleApplications/Reference/SafariWebContent/AdjustingtheTextSize/AdjustingtheTextSize.html

<!DOCTYPE HTML>
<html>
  <head>
    <title>Highlighting Elements</title>
     <style type="text/css">
      .borderImage
        {
          -webkit-tap-highlight-color:rgba(0,0,0,0);

        }       
      </style>
    </head>
<body>
   <div class="borderImage">
     <a href="#">
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vestibulum non felis risus, tristique luctus lacus. Vestibulum non aliquam arcu. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Praesent eleifend augue a ligula ornare quis lacinia risus ullamcorper.
     </a>
   </div>
</body>
</html>

这应该有效:

-webkit-tap-highlight-color:transparent

I applied this to all (*) of my html objects for my iphone web-app.我将此应用于我的 iphone 网络应用程序的所有 (*) html 对象。

Simply add this to your css code:只需将其添加到您的 css 代码中:

*{
/* Prevent any object from being highlighted upon touch event*/
-webkit-tap-highlight-color: rgba(0,0,0,0); }

I used jQuery mobile to add and handle touchstart and touchend events to my buttons, which handles the background-image of my buttons (actually these are div s), so it looks like they are pressed down on touchstart.我使用 jQuery mobile 添加和处理我的按钮的 touchstart 和 touchend 事件,它们处理我的按钮的背景图像(实际上这些是div ),所以看起来它们在 touchstart 上被按下。

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

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