跨浏览器禁用用户选择(Ctrl + A) [英] Cross browser disable the user select (Ctrl + A)
问题描述
默认情况下,用户可以拖动并选择屏幕项目/按CTRL + A,所有项目将变为蓝色和模糊(选择)。但是,有没有办法阻止这个事件?感谢
By default the user can drag and select the screen item / press CTRL + A ,all the item will be turn blue and blur (selected). However, is there any way to block this event? Thanks
有没有简单的方法,就像在浏览器中添加一些限制或在body标签中添加一些属性可以解决问题?
Are there any simple way just like adding some restriction in browser or adding some attribute in body tag can solve the problem?
推荐答案
user-select:none;
-moz-user-select: none;
-webkit-user-select: none;
-ms-user-select: none;
添加以下用户选择
属性元素,你不想变成蓝色。将其添加到正文将使可选或
可编辑
元素不能可选
或可编辑
。因此,建议在特定元素上使用它,例如
Add Following user-select
property to that element which you do not want to turn blue. Adding it to body will turn selectable
or editable
elements to not be selectable
or editable
. So, it is recommended to use it on specific elements e.g.
div, image, iframe {
user-select:none;
-moz-user-select: none;
-webkit-user-select: none;
-ms-user-select: none;
}
或者您可以查看更多:
这篇关于跨浏览器禁用用户选择(Ctrl + A)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!