CSS / JS防止拖拽幻影图像? [英] CSS /JS to prevent dragging of ghost image?

查看:888
本文介绍了CSS / JS防止拖拽幻影图像?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有一种方法可以防止用户看到他们试图拖动的图像的幽灵(不关心图像的安全性,但是体验)。

Is there a way to prevent the user from seeing a ghost of the image they are trying to drag (not concern about security of the images, but the experience).

我试过这解决了文本和图像上的蓝色选择问题,但不是鬼图像:

I've tried this which fixes the problem with the blue selection on text and images but not the ghost image:

img {
  -webkit-user-select: none;
  -khtml-user-select: none;
  -moz-user-select: none;
  -o-user-select: none;
  user-select: none;
}

(我也尝试嵌套图像在div中, div)。
感谢

(I also tried nesting the image inside a div with the same rules applied to the div). Thanks

推荐答案

您可以设置 draggable 属性 false 在标记或JavaScript代码。请参见此演示

You can set the draggable attribute to false in either the markup or JavaScript code. See this demo.

这篇关于CSS / JS防止拖拽幻影图像?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆