Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Disable the text-highlighting magnifier on touch-hold on Mobile Safari / Webkit

Tags:

iphone

webkit

I have some elements in my iPhone website that don't have any text in them but require the user to click and hold on them (DIVs). This causes the text-highlighting/editing loop/cursor to show up, which is really distracting.

I know there is a CSS rule for removing the black-box that shows up on clickable elements when they are touched. Is there anything like that to disable the text magnifier?

like image 805
3n. Avatar asked May 28 '09 23:05

3n.


People also ask

How do you stop highlighting in CSS?

To disable text selection highlighting in Google Chrome browser using CSS just set -user-select CSS property to none. And no prefix is required for Google Chrome and Opera Browsers.

How to make it so you can t select text in CSS?

You can use the user-select property to disable text selection of an element. In web browsers, if you double-click on some text it will be selected/highlighted. This property can be used to prevent this.


3 Answers

Just got a response from the Developer Center help desk. I needed to add this CSS rule:

-webkit-user-select: none;
like image 178
3n. Avatar answered Oct 19 '22 23:10

3n.


Add this to the CSS

body {
-webkit-touch-callout: none;                /* prevent callout to copy image, etc when tap to hold */
-webkit-text-size-adjust: none;             /* prevent webkit from resizing text to fit */
-webkit-user-select: none;                  /* prevent copy paste, to allow, change 'none' to 'text' */}
like image 28
Pham Van Vung Avatar answered Oct 19 '22 23:10

Pham Van Vung


Use these CSS rules:

-webkit-touch-callout: none;
-webkit-user-select: none; /* Disable selection/copy in UIWebView */
like image 6
vitralyoz Avatar answered Oct 19 '22 23:10

vitralyoz