我有一个固定的图像,当用户在触摸屏幕(移动设备)上滚动时,该图像会覆盖页面。
我希望使该图像“不可点击”、“不活跃”或其他类似的操作,以便如果用户触摸并从该图像拖动,页面仍然会滚动,就好像该图像不存在,不会“阻止”交互。
这种操作是否可行?如果需要,我可以尝试提供屏幕截图来说明我的意思。
谢谢!
设置CSS - pointer-events: none
应该能够移除所有图片的鼠标交互功能。这个属性在几乎所有浏览器中都得到了很好的支持,但IE例外。
这里是pointer-events
可以使用的完整列表。
CSS指针事件是您要查看的内容。在您的情况下,将pointer-events设置为"none"。 查看此JSFiddle示例... http://jsfiddle.net/dppJw/1/
请注意,在图标上双击仍会显示您单击了段落。
div.child {
...
background: #fff;
pointer-events: none //This line is the key!
}
如果你想使用JavaScript:
document.getElementById("x").style.pointerEvents = "none";
<a href="https://www.google.com" id="x" />Unclickable Google Link</a>
<br>
<a href="https://www.google.com" id="" />Clickable Google Link</a>
#button{
pointer-events: none;
}
<button id="button">Unclickable!</button> <!-- The element -->
pointer-events
,这正是我要找的。谢谢! - hannebaumsawayunbind
和bind
可能会起作用。不过还是感谢您的回复! - Dusty