Thursday, 6 February 2014

Safari text input fields and -webkit-user-select: none;

I've been using this in my css to prevent selection of text with long presses:
/* remove touch callout - visible when pressing and holding a link */
* {
-webkit-touch-callout: none;
-webkit-user-select: none;
}
But I discovered today that in Safari only (including iPhone) this actually prevents the input/edit of text in an text input box. The fix is to override the css for inputs like so:
input {
    -webkit-user-select: auto !important;
}

No comments:

Post a Comment

Comments are moderated, so you'll have to wait a little bit before they appear!