【发布时间】:2019-09-10 08:24:40
【问题描述】:
我正在尝试使用 CSS 禁用输入字段中文本值的选择突出显示。我已经使用下面的代码为文本禁用了它,但它不适用于输入字段:
.inputTest {
-webkit-touch-callout: none;
-webkit-user-select: none;
-khtml-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
}
【问题讨论】:
-
input[type="text"]::selection { background-color: transparent }怎么样? -
为什么不直接在输入中使用
disabled语法,比如<input type="text" disabled> -
不要一开始就搞乱基本的 UI 功能怎么样?输入字段中的文本不会被意外选中,如果我这样做,我可能有我的理由。
-
@misorude - 我需要为 Vive Focus Android WebView 执行此操作以禁用选择和上下文菜单,这在 VR 中没有任何用途。 CSS 工作,但不幸的是没有禁用上下文菜单。我在 JS 中尝试了许多解决方案,但没有一个有效。