IE中的z-index问题与透明div [英] z-index problem in IE with transparent div

查看:157
本文介绍了IE中的z-index问题与透明div的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个透明的div元素具有比同一页上的img元素更高的z-index。但是Internet Explorer的行为好像img-element在点击事件时会有更高的z值。

 < ;!DOCTYPE html> 
< html>
< head>
< title>演示< / title>
< / head>
< body style =margin:0; padding:0;>
< img src =7player.pngalt =7playerwidth =60height =60style =position:absolute; left:100px; top:100px; z-index:10 />
< div style =width:100%; height:100%; position:absolute; z-index:900; onclick =alert('hello');>< / div>
< / body>
< / html>

点击图片时,div元素的点击事件应该被触发

解决方案



/ div>

其实你的div没有任何背景,



你需要给它一个颜色背景0.01。



例如:

  filter:alpha(opacity = 1); 


I have a transparent div-element with a higher z-index than an img-element on the same page. But Internet Explorer is acting as if the img-element would have a higher z-value when it comes to click events.

<!DOCTYPE html>
<html>
<head>
    <title>Demo</title>
</head>
<body style="margin:0;padding:0;">
    <img src="7player.png" alt="7player" width="60" height="60" style="position:absolute; left: 100px; top: 100px; z-index:10" />
    <div style="width:100%;height:100%;position:absolute;z-index:900;" onclick="alert('hello');"></div>
</body>
</html>

When clicking on the image nothing happens altough the click event of the div-element should be fired (works in Chrome for example).

Is there any workaround or fix for my problem?

解决方案

In fact, your div "Doesn't have any background",

You need to give it a color background (e.g. white) with opacity=0.01.

For example:

 background:white; filter:alpha(opacity=1);

这篇关于IE中的z-index问题与透明div的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆