Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Is there any way to apply this to a div?

like image 720
tarnfeld Avatar asked Dec 29 '09 13:12

tarnfeld


3 Answers

I applied this to all (*) of my html objects for my iphone web-app.

Simply add this to your css code:

*{
/* 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 divs), so it looks like they are pressed down on touchstart.

like image 149
Tom Vos Avatar answered Oct 04 '22 11:10

Tom Vos


This should work:

-webkit-tap-highlight-color:transparent
like image 26
John Doe Avatar answered Oct 04 '22 10:10

John Doe


Are you writing for iPhone/Smartphone websites? 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. The div would have to be affected by some kind of scripting, or be a link.

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>
like image 39
tahdhaze09 Avatar answered Oct 04 '22 12:10

tahdhaze09