虚拟主机域名注册-常见问题网络编程问题 → CSS/HTML


禁止文字选中兼容IE/Chrome等浏览器 css方法
作者:

如果让整个页面都禁止选择,可以使用下面的css

body{
-webkit-touch-callout: none;
-webkit-user-select: none;
-khtml-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
}

如果希望指定元素禁止访问,请看下面的示例代码:

<!doctype html>
<html>
<head>
<style type="text/css">
*.unselectable {
   -moz-user-select: -moz-none;
   -khtml-user-select: none;
   -webkit-user-select: none;

   /*
     Introduced in IE 10.
     See http://ie.microsoft.com/testdrive/HTML5/msUserSelect/
   */
   -ms-user-select: none;
   user-select: none;
}
</style>
</head>

<body>

<div class="unselectable">
<p>这是很长的一段文本。啦啦啦啦啦啦</p>
</div>

</body>
</html>


来源:
阅读:4553
日期:2017-09-20

推荐朋友 】 【 评论 】  【 字体: 】 
上一篇:input type=file 样式美化方法
下一篇:返回上一页并刷新的代码
  >> 相关文章
 
发表评论


点  评: 字数0
用户名:  密码:

  • 尊重网上道德,遵守中华人民共和国的各项有关法律法规
  • 承担一切因您的行为而直接或间接导致的民事或刑事法律责任
  • 本站管理人员有权保留或删除其管辖留言中的任意内容
  • 本站有权在网站内转载或引用您的评论
  • 参与本评论即表明您已经阅读并接受上述条款