CSS中透明度filter: Alpha(Opacity= 再iframe中再次使用出错

天齐贺少 天齐贺少 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
有个index页面,里面有个iframe. 其中index页面设置iframe的透明度为85,在iframe中有个进度条也有设置一个层的透明度,但是运行后出现层级混乱,去掉index的85透明度,运行正常,但是必须使用85透明度,下面是2个html代码,大家都来看看怎么修改才会在85的透明度下正常
将2个代码复制进去,运行index.html既能看见效果

方便大家调试,把代码附上,纯html
index.html代码

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
<style>
body{background-color:#3399CC;}
.iframe{filter: Alpha(Opacity=85)}
</style>
</head>
<body>
<iframe src="iframe.html" width="100%" height="600px" frameBorder="0" class="iframe" scrolling="no" ></iframe>
</body>
</html>


iframe.html代码

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
<style>
body{ background-color: transparent;}
.mydiv
{
font-weight: bold;
z-index: 9;
left: 45%;
top: 48%;
margin-left: -150px!importnt; /*FF IE7 该值为本身宽的a一半 */
margin-top: -60px !important; /*FF IE7 该值为本身高的一半*/
margin-top: 0px;
position: fixed !important; /* FF IE7*/
position: absolute; /*IE6*/
_top: expression(eval(document.compatMode && document.compatMode=='CSS1Compat') ? documentElement.scrollTop + (document.documentElement.clientHeight-this.offsetHeight)/2 : /*IE6*/ document.body.scrollTop + (document.body.clientHeight - this.clientHeight)/2); /*IE5 IE5.5*/
}
.bg, .popIframe
{
background-color: #CCCCCC;
display: none;
width: 100%;
height: 100%;
left: 0;
top: 0; /*FF IE7*/
filter: alpha(opacity=50); /*IE*/
opacity: 0.5; /*FF*/
z-index: 1;
position: fixed !important; /*FF IE7*/
position: absolute; /*IE6*/
_top: expression(eval(document.compatMode && document.compatMode=='CSS1Compat') ? documentElement.scrollTop + (document.documentElement.clientHeight-this.offsetHeight)/2 : /*IE6*/ document.body.scrollTop + (document.body.clientHeight - this.clientHeight)/2);
}
.popIframe
{
filter: alpha(opacity=0); /*IE*/
opacity: 0; /*FF*/
}
</style>
<script>
function showDiv() {
document.getElementById('popDiv').style.display = 'block';
document.getElementById('popIframe').style.display = 'block';
document.getElementById('bg').style.display = 'block';
}
function closeDiv() {
document.getElementById('popDiv').style.display = 'none';
document.getElementById('bg').style.display = 'none';
document.getElementById('popIframe').style.display = 'none';
}
</script>
</head>

<body>
<input type="button" onclick="showDiv()" value="点击进入进度" />
<div id="popDiv" class="mydiv" style="display:none;">
<img src="http://www.23ps.com/Files/UpLoadFile/201106/201106091504386485.gif" />
</div>
<div id="bg" class="bg" style="display:none;"></div>
<iframe id='popIframe' class='popIframe' frameborder='0' ></iframe>
</body>
</html>

...全文
评论 4
收藏 已收藏
分享
返回顶部
天齐贺少
.NET社区 62,275 成员 668,968 内容