Click through div to underlying elements(单击 div 到底层元素)
问题描述
我有一个 div
,它具有 background:transparent
以及 border
.在这个div
下面,我有更多的元素.
I have a div
that has background:transparent
, along with border
. Underneath this div
, I have more elements.
目前,当我单击覆盖层div
之外时,我能够单击基础元素.但是,当直接单击覆盖 div
时,我无法单击基础元素.
Currently, I'm able to click the underlying elements when I click outside of the overlay div
. However, I'm unable to click the underlying elements when clicking directly on the overlay div
.
我希望能够点击这个 div
以便我可以点击底层元素.
I want to be able to click through this div
so that I can click on the underlying elements.
推荐答案
是的,你可以这样做.
使用 pointer-events: none
和 IE11 的 CSS 条件语句(不适用于 IE10 或更低版本),您可以获得针对此问题的跨浏览器兼容解决方案.
Using pointer-events: none
along with CSS conditional statements for IE11 (does not work in IE10 or below), you can get a cross browser compatible solution for this problem.
使用 AlphaImageLoader
,您甚至可以将透明的 .PNG/.GIF
放在覆盖层 div
中,并让点击流向下方的元素.
Using AlphaImageLoader
, you can even put transparent .PNG/.GIF
s in the overlay div
and have clicks flow through to elements underneath.
CSS:
pointer-events: none;
background: url('your_transparent.png');
IE11 条件:
filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src="eW91cl90cmFuc3BhcmVudC5wbmc=", sizingMethod='scale');
background: none !important;
这是一个基本示例页面包含所有代码.
Here is a basic example page with all the code.
这篇关于单击 div 到底层元素的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:单击 div 到底层元素


- 如何向 ipc 渲染器发送添加回调 2022-01-01
- 我不能使用 json 使用 react 向我的 web api 发出 Post 请求 2022-01-01
- 在不使用循环的情况下查找数字数组中的一项 2022-01-01
- 从原点悬停时触发 translateY() 2022-01-01
- 使用 iframe URL 的 jQuery UI 对话框 2022-01-01
- 如何调试 CSS/Javascript 悬停问题 2022-01-01
- 为什么悬停在委托事件处理程序中不起作用? 2022-01-01
- 是否可以将标志传递给 Gulp 以使其以不同的方式 2022-01-01
- 为什么我的页面无法在 Github 上加载? 2022-01-01
- 如何显示带有换行符的文本标签? 2022-01-01