How to use user-select to prohibit text selection in CSS
This article mainly explains "how to use user-select to prohibit text selection in CSS". The content in the article is simple and clear, and it is easy to learn and understand. Please follow the editor's train of thought to study and learn "how to use user-select to prohibit text selection in CSS".
User-select has two values:
None: users cannot select text
Text: users can select text
It should be noted that user-select is not a W3C CSS standard attribute, the browser support is incomplete, and each browser needs to be adjusted.
The code is as follows:
Body {
-moz-user-select: none; / * Firefox * /
-webkit-user-select: none; / * webkit browser * /
-ms-user-select: none; / * IE10*/
-khtml-user-select: none; / * early browser * /
User-select: none
}
IE6-9 has not found any related CSS attributes.
The code is as follows:
/ / IE6-9
Document.body.onselectstart = document.body.ondrag = function () {
Return false
}
Thank you for your reading, the above is the content of "how to apply user-select to prohibit text selection in CSS". After the study of this article, I believe you have a deeper understanding of how to use user-select to prohibit text selection in CSS, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!