首页 > 开发 > CSS > 正文

CSS禁止文字选择user-select应用

2024-07-11 08:39:22
字体:
来源:转载
供稿:网友

user-select有两个值:

none:用户不能选择文本

text:用户可以选择文本

需要注意的是:user-select并不是一个W3C的CSS标准属性,浏览器支持的不完整,需要对每种浏览器进行调整


body{
-moz-user-select: none; /*火狐*/
-webkit-user-select: none; /*webkit浏览器*/
-ms-user-select: none; /*IE10*/
-khtml-user-select: none; /*早期浏览器*/
user-select: none;
}

IE6-9还没发现相关的CSS属性


//IE6-9
document.body.onselectstart = document.body.ondrag = function(){
return false;
}

发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表