我已经看到/听说过使用 user-select
的变体禁用文本选择的所有内容,但这些都不能解决我遇到的问题。在 Android 上(我猜是在 iPhone 上),如果你点击并按住文本,它会突出显示它并显示一些小标志来拖动和选择文本。我需要禁用这些(见图):
我试过 -webkit-touch-callout
无济于事,甚至尝试过 $('body').on('select',function(e){ e.preventDefault();return;});
无济于事。而像 ::selection:rgba(0,0,0,0);
这样的廉价技巧也不起作用,因为隐藏它们也无济于事 - 选择仍然会发生并且它会破坏 UI。另外,我猜这些标志仍然存在。
任何想法都会很棒。谢谢!
最佳答案
-webkit-touch-callout:none;
-webkit-user-select:none;
-khtml-user-select:none;
-moz-user-select:none;
-ms-user-select:none;
user-select:none;
-webkit-tap-highlight-color:rgba(0,0,0,0);
这将为每个正在运行的浏览器禁用它。
关于android - 移动网络 - 禁用长按/点击文本选择,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11237936/