语法
Formal syntax: none | text | all | element
复制代码代码如下:
(-prefix-)user-select: none;
(-prefix-)user-select: text;
(-prefix-)user-select: all;
(-prefix-)user-select: element;
示例
复制代码代码如下:
.row-of-icons {
-webkit-user-select: none;
-moz-user-select: none;
-ms-user-select: none; </p><p>
-o-user-select: none;
user-select: none;
}
IE兼容性
目前在IE 10以及IE 10以上版本的浏览器可以使用-ms-user-select这个规则,但在更早版本的IE,我们只能通过javascript实现禁止选中文本:
复制代码代码如下:
$(el).attr('unselectable','on')
.css({'-moz-user-select':'-moz-none',
'-moz-user-select':'none',
'-o-user-select':'none',
'-khtml-user-select':'none',
'-webkit-user-select':'none',
'-ms-user-select':'none',
'user-select':'none'
}).bind('selectstart', function(){
return false;
});