了解如何使用CSS属性`用户选择'来禁止文本选择
默认情况下,浏览器会让我们在浏览器中使用键盘选择文本,例如在Mac上按cmd-A组合,或者使用鼠标。
你怎样才能禁用这一点,使你的网页表现得更像一个应用程序,而不像一个文档?
使用user-select: none; CSS规则。
你需要使用浏览器的前缀,正如caniuse.com/#feat=user-…告诉我们的。
-webkit-touch-callout: none;
-webkit-user-select: none;
-khtml-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
我有时使用的一个方法是,在body元素上应用user-select: none; ,使所有的应用程序界面不可选择,然后我可以在特定的元素上重新启用它,使用。