【发布时间】:2011-08-31 05:19:11
【问题描述】:
我正在尝试构建一个简单的淡入淡出效果。我使用两个包含图像的 div。两者都有“位置:绝对”属性和负 z-index。
我将补间函数应用于 Firefox 和 Chrome 中的不透明度样式属性。我对 IE 使用 filter: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;
}
非常感谢
【问题讨论】:
标签: javascript internet-explorer-7 opacity