CSS中用户拖动和用户选择之间的区别

时间:2018-09-17 13:54:16

标签: css drag-and-drop draggable

<input type="button" onclick="addRow()" value="Add Item"/> user-select属性之间的主要区别是什么?所有浏览器都支持它们吗?

2 个答案:

答案 0 :(得分:0)

主要区别在于,user-select允许您选择然后复制某些内容(如果需要),而user-drag则允许您拖动某些内容,例如HTML元素。

我知道user-select可以在不同的浏览器中使用,但是您应该设置CSS规则,如下所示:

-webkit-user-select: all; 
-moz-user-select: all; 
-ms-user-select: all;
user-select: all; 

答案 1 :(得分:0)

默认情况下,如User Select - MDN web Docs中所述,用户选择特定于.fixed-div{ position: fixed; left: 50vw; top: 30vh; transform: translate(-50%, -50%); /* Moves the center of the element to its original top left corner*/ z-index: 1; } ,对文本启用用户选择。要禁用该属性,请使用下面提到的CSS样式。

text

User Drag是通用的,可以应用于-moz-user-select: none; -webkit-user-select: none; -ms-user-select: none; user-select: none;

div, image, p, etc.,

下面是用于用户拖动的CSS

<p draggable="true">Contents</p> //Enable dragging
<img src="image.jpg" draggable="false" alt="can't be dragged"></img> //Disable dragging