首页 > Web开发 > 详细

css禁止用户选择文本(兼容所有浏览器)

时间:2017-04-05 16:22:44      阅读:318      评论:0      收藏:0      [点我收藏+]

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>

css禁止用户选择文本(兼容所有浏览器)

原文:http://www.cnblogs.com/callmeguxi/p/6668998.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!