首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >CSS指针-事件IE10和IE11旧版本

CSS指针-事件IE10和IE11旧版本
EN

Stack Overflow用户
提问于 2018-09-25 17:43:21
回答 2查看 1K关注 0票数 0
代码语言:javascript
复制
#values43011009create {
    pointer-events: none;
    background-color: #f9f9f9;
}

此代码在IE 10中不起作用,但在IE 11及更高版本中运行良好。

我也需要一个较低版本的IE的修复。非常感谢您的帮助。

EN

回答 2

Stack Overflow用户

发布于 2018-09-25 17:57:22

另一种解决方案是在链接顶部添加一个Psuedo ::after元素,作为防止被点击的封面:

代码语言:javascript
复制
.yourlink {
    position: relative;
    z-index: -1
}

.yourlink::after {
    content: ' ';
    background-color: #fff;
    position: absolute;
    height: 100%;
    top: 0;
    left: 0;
    opacity: 0;
    width: 100%;
    z-index: 250; 
}

如果你想只在IE浏览器上这样做,而不是Firefox或Chrome,那么你可以将所有这些都封装在一个只针对IE的媒体查询中:

代码语言:javascript
复制
@media screen and (-ms-high-contrast: active), (-ms-high-contrast: none) {
    .yourlink {
        position: relative;
        z-index: -1
    }

    .yourlink::after {
        content: ' ';
        background-color: #fff;
        position: absolute;
        height: 100%;
        top: 0;
        left: 0;
        opacity: 0;
        width: 100%;
        z-index: 250; 
    }
}

下面是该解决方案的一个示例:https://jsfiddle.net/Ly06krt3/23/

票数 0
EN

Stack Overflow用户

发布于 2018-09-26 14:20:32

为了防止click事件,您可以参考下面的示例。

代码语言:javascript
复制
var handler = function(e)
{
    e = e || window.event;
    var target = e.target || e.srcElement;
    if (target.tagName.toLowerCase() === 'a')
    {
        if (!e.preventDefault)
        {//IE quirks
            e.returnValue = false;
            e.cancelBubble = true;
        }
        e.preventDefault();
        e.stopPropagation();
    }
};
if (window.addEventListener)
    window.addEventListener('click', handler, false);
else
    window.attachEvent('onclick', handler);

参考资料:

“pointer-events: none” does not work in IE9 and IE10

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/52495116

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档