首页  >  文章  >  web前端  >  html 怎么设置文字无法选中

html 怎么设置文字无法选中

藏色散人
藏色散人原创
2021-11-10 14:24:326876浏览

html设置文字无法选中的方法:1、创建HTML页面文件;2、通过设置css样式为“user-seletct: none;-webkit-user-seletct: none;-moz-user-seletct: none;”即可。

html 怎么设置文字无法选中

本文操作环境:windows7系统、HTML5版、DELL G3电脑

html 怎么设置文字无法选中?

控制HTML页面内容不能选中的方法

方法有二

一: css 方法

user-seletct: none;
-webkit-user-seletct: none;
-moz-user-seletct: none;
-ms-user-seletct: none;

none: 不能选中内容

text: 能选中内容

二:js 方法

document.body.onselectstart = function(){
  return false;
}

返回 false,不能选中

返回 true,能选中

推荐学习:《HTML5视频教程

以上是html 怎么设置文字无法选中的详细内容。更多信息请关注PHP中文网其他相关文章!

声明:
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn