首页 > 技术文章 > ie10兼容问题 -- 将div定位absolute在图片img上面,导致div点击事件无效

juewuzhe 2019-12-03 10:21 原文

ie10兼容问题:

将div定位absolute在图片img上面,发现div若不加背景色,导致div点击事件(任何事件)无效。

<div class="paper-box">
    <div class="red-paper">
       <img class="company-uk-packet" src="./images/uk-bag.png" alt="">
    </div>
    <div class="hand-hot"></div>
</div>

解决办法:

1、给div本身加透明背景色(前提是该div里没有内容,否则内容也会被透明)

.hand-hot{
    position: absolute;
    width:220px;
    height: 54px;
    bottom:22px;
    left:102px;
    cursor: pointer;
    background: #fff;
    opacity: 0;
}

2、将img换成背景图

.red-paper{
    width:430px;
    height: 430px;
    background: url('../images/uk-bag.png') no-repeat center center;
}
.hand-hot{
    position: absolute;
    width:220px;
    height: 54px;
    bottom:22px;
    left:102px;
    cursor: pointer;
}

 

推荐阅读