css禁用选中文本
By default browsers let us select the text in the browser using the keyboard, pressing the cmd-A combination on a Mac for example, or using the mouse.
默认情况下,浏览器允许我们使用键盘,例如在Mac上按cmd-A组合或使用鼠标在浏览器中选择文本。
How can you disable that, to make your web page behave more like an app and less like a document?
如何禁用它,以使网页的行为更像是应用程序,而不像文档一样?
Use the user-select: none;
CSS rule.
使用user-select: none;
CSS规则。
You need to use browser prefixes, as https://caniuse.com/#feat=user-select-none tells us:
您需要使用浏览器前缀,如https://caniuse.com/#feat=user-select-none告诉我们:
-webkit-touch-callout: none;
-webkit-user-select: none;
-khtml-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
One thing I use sometimes is to make all the app interface unselectable applying user-select: none;
on the body element, then I can re-enable it on specific elements, using:
有时,我使用的一件事是通过user-select: none;
使所有应用程序界面变为不可user-select: none;
在body元素上,然后可以使用以下命令在特定元素上重新启用它:
user-select: text;
css禁用选中文本