2
我正在尝试构建一个简单的淡入淡出效果。我使用两个包含图像的div。两者都有“位置:绝对”属性和负Z指数。CAN IE7显示两个不同不透明度的div在另一个之上?
我将补间函数应用于Firefox和Chrome中的不透明度样式属性。我为IE使用过滤器:alpha(opacity = foo)。
我看到我的'旧'图像淡出,但是'新'图像立即显示在我的'旧'图像的顶部,不管z-index和不透明度值如何。
我知道IE7有一些不透明的问题,但我不确定这是否是其中之一。我使用JPEG文件,而不是.PNG。任何人都可以解释我做错了什么吗?
一些代码:
var temporaryDiv = document.createElement("div");
var temporaryDivImage = document.createElement("img");
document.body.appendChild(temporaryDiv);
temporaryDiv.appendChild(temporaryDivImage);
temporaryDivImage.src = backgroundPictures[currentPicture + 1];
temporaryDiv.setAttribute("style", "overflow: hidden; filter: alpha(opacity=0); position: absolute; z-index: -2;");
document.body.appendChild(temporaryDiv);
var background = document.getElementById("background");
if (isIE7 == true) {
Tweens[0] = new Tween(temporaryDiv.style, "filter", Tween.linearIn, 0, 100, 2000, "alpha(opacity=", ")");
Tweens[1] = new Tween(background.style, "filter", Tween.linearIn, 100, 0, 2000, "alpha(opacity=", ")");
}
CSS:
body {
margin: 0px;
width: 100%;
height: 100%;
}
#background {
position: absolute;
overflow: hidden;
z-index: -1;
}
非常感谢
谢谢!我只是通过将所有的z-index改为正整数来意外地解决了这个问题,我会明白你的解决方案明天是否会工作太多.. – Mansiemans 2011-05-23 20:54:17