Browser support
Currently, only Gecko and WebKit support this property, including essentially all versions of Firefox/chrome/safari,ie10. Of course, each browser has to add a private prefix. Opera is not yet supported.
Perhaps you often don't want users to choose text on your site, whether it's for copyright reasons or not. Usually you will have JS to implement, and the other is to set the value of-webkit-user-select and-moz-user-select to none, which can be useful for mobile users.
Use this property with caution: Because most users are looking for information that they can copy and store for future use, this method is both useless and ineffective. If you disable the copy and Paste feature, users can still view the source files to get what they want.
| code is as follows |
copy code |
body {
-webkit-touch-callout:none;
-webkit-user-select:none;
-khtml-user-select:none;
-moz-user-select:none;
-ms-user-select:none;
User-select:none;
}
|
The above code is compatible with all mobile device browsers, so let's take a look at some of the introductions to User-select.
Attached: introduction of User-select
User-select is a new feature in the CSS3 UI specification to control the selectivity of content.
Grammar
User-select:value;
Optional parameters
auto--The default value, the user can select the contents of the element
none--users cannot select any content in an element
text--users can select text in an element
element--text is optional, but only within the bounds of the element (IE and FF support only)
all--in the editor, if the double-click/context click occurs on the child element, the most advanced ancestor element of the change is selected.
-moz-none--firefox private, the text of elements and child elements is not selectable, but child elements can be reset by text to be optional.
Using the sample
| The code is as follows |
Copy Code |
|
. selectdemo{
Background-color: #eee;
padding:20px;
-moz-user-select:none;
-webkit-user-select:none;
-ms-user-select:none;
} |
If you want to support all of us, we can
| The code is as follows |
Copy Code |
|
<script type= "Text/javascript" >document.oncontextmenu=function (e) {return false; Document.onselectstart=function (e) {return false;}; </script><style>body{-moz-user-select:none;} </style> |
You can add this sentence
Summarize
This property, which was previously used to protect the content of the Web site, not be copied and reproduced by the user, thereby protecting the copyright of the information, but this is to the user experience of ordinary users caused harm, and, and can not really protect the content of the page, which for the front-end developers, directly to see the source code can copy the problem in the page.
Now that HTML5 is booming, many Web sites or Web apps will use drag and drop technology, user-select just in some situations.