【发布时间】:2023-03-16 23:05:01
【问题描述】:
下面是我的代码。
在ie浏览器中打开页面,然后选择div中的文字,文字会以阴影四边形空白显示。如果删除一行 z-索引:0, 在 css 类 test1 中,ie 将正确执行。
在我的项目中,z-index 必须设置大于零,所以我无法删除该行。
我找到了一个解决方案,当pannel.z-index大于0时设置bg_img.filter = "",那么ie也可以正常工作。但不幸的是,bg_img.filter.alpha 也必须设置。
那我该怎么办?
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script language="javascript" src="scripts/im_test.js"></script>
<title>test</title>
<style type="text/css">
.test1 {
position:absolute;
background:#ffffff;
left:20px;
top:20px;
border:1px solid;
width:198px;
height:500px;
filter: progid:DXImageTransform.Microsoft.Shadow(color="#999999", Direction=135, Strength=5);
z-index:0;
}
</style>
<script>
function init ()
{
var pannel = document.createElement ('div');
var bg_img = document.createElement ('div');
var head = document.createElement ('div');
pannel.setAttribute('class', 'test1');
pannel.setAttribute('className', 'test1');
bg_img.style.cssText = "position:relative;left:0px;top:0px;"
+ "width:198px;"
+ "height:500px;"
+ "filter:alpha(opacity=100);";
head.style.cssText = "position:absolute;"
+ "left:0px;"
+ "top:0px;"
+ "width:180px;"
+ "height:20px;";
document.body.appendChild (pannel);
pannel.appendChild(bg_img);
pannel.appendChild(head);
head.innerHTML = "<div>yusutechasdf</div><div>innerhtml</div>"
}
</script>
</head>
<body onload="init()">
</body>
</html>
【问题讨论】:
标签: css internet-explorer javascript