• 技术文章 >web前端 >前端问答

    html 怎么设置文字无法选中

    藏色散人藏色散人2021-11-10 14:24:32原创54

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

    本文操作环境: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中文网其它相关文章!

    声明:本文原创发布php中文网,转载请注明出处,感谢您的尊重!如有疑问,请联系admin@php.cn处理
    专题推荐:html
    上一篇:html5 怎么禁止滚动 下一篇:html 删除线标签是什么
    大前端线上培训班

    相关文章推荐

    • html如何设置禁止选中• css如何禁止选中页面内容• html如何取消文本选中• 怎么设置css文本不可选中

    全部评论我要评论

  • 取消发布评论发送
  • 1/1

    PHP中文网