css3控制内容的可选择性

时间:2023-03-10 04:03:19
css3控制内容的可选择性

<!doctype html>
<html>
<head>
<meta charset="UTF-8">
<meta name="Author" content="胡超">
<title>super胡</title>
<style>
div{
text-align:center;
height:39px;
-moz-user-select:none;
-o-user-select:none;
-webkit-user-select:none;
-ms-user-select:none;
user-select:none;
/*IE6-9不支持该属性,但支持使用标签属性 onselectstart="return false;" 来达到 user-select:none 的效果;Safari和Chrome也支持该标签属性;
直到Opera12.5仍然不支持该属性,但和IE6-9一样,也支持使用私有的标签属性 unselectable="on" 来达到 user-select:none 的效果;unselectable 的另一个值是 off;
除Chrome和Safari外,在其它浏览器中,如果将文本设置为 -ms-user-select:none;,则用户将无法在该文本块中开始选择文本。不过,如果用户在页面的其他区域开始选择文本,则用户仍然可以继续选择将文本设置为 -ms-user-select:none; 的区域文本;*/
}
</style>

</head>
<body>
<div onselectstart="return false;" unselectable="on">
找不到
</div>
</body>
</html>

相关文章