我陷入了不透明的问题......
我有这个HTML结构
<body>
<div id="G_I_Error"></div>
<div id="main">
<!-- some stuff -->
</div>
</body>
然后,用JS修改“主”不透明度。
但是,对于IE8,“main”的子元素始终具有相同的不透明度(100)......
如何让孩子与“主”具有相同的不透明度?
答案 0 :(得分:0)
我有几个DIV ......就像这样:
<div class="main" id="main">
<div class="top">
<span class="logoNameText">MY WEBSITE</span>
<form name="li" action="#" method="post">
</form>
</div>
<div class="content">
</div>
<script>launchError(1);<script>
</div>
是登录页面......
JS代码非常简单:
function launchError(c){
t='';
if(c==1){
t='<span id="Close" onclick="dimiss(1);">x</span><span id="Error"><b>Error opening session</b><br /><a href="#">Forgot your password?</a></span>';
}else if(c==2){
t='<span id="Close" onclick="dimiss(1);">x</span><span id="Error"><b>Error during register: </b><br />Inserted emails don\'t match</span>';
}else if(c==3){
t='<span id="Close" onclick="dimiss(1);">x</span><span id="Error"><b>Error during register: </b><br />Inserted passwords don\'t match</span>';
}else if(c==4){
t='<span id="Close" onclick="dimiss(1);">x</span><span id="Error"><b>Error during register: </b><br />Inserted email is already registered</span>';
}
if(c<=4){
document.getElementById('G_I_Error').innerHTML=t;
setOpacity(document.getElementById('main'), 50);
document.re.d.setAttribute('onclick', 'voidFunction();');
}
}
function setOpacity(e,o){
e.style.opacity=o/100;
e.style.MozOpacy=o/100;
e.style.filter='alpha(opacity='+o+')';
}
然后,CSS也很简单。
.main{margin-left:auto;margin-right:auto;margin-top:auto;width:1000px;}
.top{height:98px;}
.content{top:20px;height:500px;position:relative;}
......我希望它有所帮助。