解决问题:双击鼠标选中一段文本,经常被恶心到了。
解决方式,为 html 设置如下样式:
html {
-webkit-touch-callout: none; /* iOS Safari */
-webkit-user-select: none; /* Chrome/Safari/Opera */
-khtml-user-select: none; /* Konqueror */
-moz-user-select: none; /* Firefox */
-ms-user-select: none; /* Internet Explorer/Edge */
user-select: none; /* Non-prefixed version, currently not supported by any browser */
}
user-select 属性值默认为“text”
当有需要选中文本的地方可以设置一个类,然后为需要选择的地方添加这个类,如:
.canSelect {
-webkit-touch-callout: text;
-webkit-user-select: text;
-khtml-user-select: text;
-moz-user-select: text;
-ms-user-select: text;
user-select: text;
}