【问题标题】:-webkit-tap-highlight-color: rgba(0,0,0,0); on a div?-webkit-tap-highlight-color: rgba(0,0,0,0);在一个div上?
【发布时间】:2010-12-30 18:55:12
【问题描述】:

有没有办法将它应用到 div 上?

【问题讨论】:

    标签: javascript css ios webkit dom-events


    【解决方案1】:

    您正在为 iPhone/智能手机网站写作吗?如果是这样,那么是的。但您可能只会在手机/模拟器上看到结果。我认为这个元素只能用于链接或 javascript 元素。 div 必须受到某种脚本的影响,或者是一个链接。

    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>
    

    【讨论】:

    • 糟糕的一天!卡洛!卡莱!我一直在寻找一种方法来禁用该被诅咒的橙色高光。它就在那里。谢谢!
    • 很高兴您发现这很有用!
    • 太糟糕了,我不能超过 +1。 :)
    【解决方案2】:

    这应该有效:

    -webkit-tap-highlight-color:transparent
    

    【讨论】:

      【解决方案3】:

      我将此应用于我的 iphone 网络应用程序的所有 (*) html 对象。

      只需将其添加到您的 css 代码中:

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

      我使用 jQuery mobile 向我的按钮添加和处理 touchstart 和 touchend 事件,它们处理我的按钮的背景图像(实际上这些是 divs),所以看起来它们在 touchstart 上被按下了。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2011-11-22
        • 2014-01-18
        • 2012-01-21
        • 2011-03-10
        • 2016-11-26
        • 1970-01-01
        • 2015-04-09
        • 1970-01-01
        相关资源
        最近更新 更多