html - 如何防止图片叠加不可点击

标签 html css

我在企业中有以下横幅设计:

enter image description here (点击图片查看完整图片。)

现在存在以下BUG,我先给大家看一下:

enter image description here (点击查看全图)。

现在标题需要放在下面很多,但是因为我已经使用了一个图像并且绝对定位了它,所以红色区域实际上仍然是图像。我需要它成为横幅,因为点需要可点击。

我该怎么做,我尝试过的一个解决方案是使用 div 而不是图像,给它一个高度,然后将图像添加为背景,但这相当于做同样的事情并且创建相同的东西错误,我知道这是一个很难解决的问题,但我可以使用图像并仍然摆脱 I.E.没有这个错误,这就是我现在正在寻找的,我知道可能有 Canvas 或 SVG 解决方案,但我不能为这个元素使用 Canvas 或 SVG。

bug可见 HERE .

谢谢。

最佳答案

将“pointer-events: none”应用于您的图像,然后它将起作用:

.curved-img-wrpr img {
    pointer-events: none;
}

图片现在不会遮挡下方的元素。

MDN 解释:

In addition to indicating that the element is not the target of mouse events, the value none instructs the mouse event to go "through" the element and target whatever is "underneath" that element instead.

我相信 MDN 的解释非常概括了这一点。

关于html - 如何防止图片叠加不可点击,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35499970/

相关文章:

jquery - 在 FF 中设置宽度时 Div 不包含另一个元素

JavaScript动画滑动菜单

html - Windows(Chrome、Edge 等)和 Macos(Safari)中的边距不同

php - 在 mPDF 上呈现 CSS 的问题 - PHP

html - 更改移动设备上的 Bootstrap 顺序 - 3 个不同的框

javascript - 我怎样才能让 IE 忽略一个类?

html - 连续得到 10 个二次方 block

html - 元标记 'there is no attribute "property"' 等属性错误 :

html - margin-left(以百分比设置)随着 Chrome 中的每个元素缩小(而不是在 Firefox 中)

html - 如何控制边框高度?