背景不透明度
有没有办法保持元素的背景不受不透明度的影响?
IE 我有一个 jquery 手风琴,当单击/悬停时,特定元素(li)的内容不透明度会发生变化,导致您看到下面的其他元素。
我想知道是否可以更改它,因此每个列表元素上都有一个不会褪色的纯白色背景?
一些代码:
<div id="accord_container"><div id="accord">
<ul>
<li><a id="a1"><img src="img/accord/1.jpg" /></a></li>
<li><a id="a2"><img src="img/accord/3.jpg" /></a></li>
<li><a id="a3"><img src="img/accord/7.jpg" /></a></li>
<li><a id="a4"><img src="img/accord/8.jpg" /></a></li>
</ul>
</div></div>
#accord_container{width:930px; margin:0px auto;}
#accord{height:480px; overflow:hidden; margin:5px; position:relative; cursor:pointer;}
#accord ul{position:relative; list-style:none; margin:0; padding:0;}
#accord ul li{float:left; display:block; margin-right:0px; background-color:#FFF;}
#accord ul li a{display:block; overflow:hidden; height:480px; width:72px; opacity:0.75; -ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=75)"; filter:alpha(opacity=75);}
#accord ul li img{position:absolute;}
#a1{width:700px; opacity:1.0; -ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=100)"; filter:alpha(opacity=100);}
$(document).ready(function(){
lastBlock = $("#a1");
maxWidth = 700;
minWidth = 72;
$("#accord ul li a").click(
function(){
if(lastBlock.id == this.id || (lastBlock.id == undefined && this.id == "a1")){
if(this.rel){
window.location=this.rel;
}
}else{
$(lastBlock).animate({width: minWidth+"px", opacity: 0.75}, { queue:false, duration:400});
$(this).animate({width: maxWidth+"px", opacity: 1.0}, { queue:false, duration:400});
lastBlock = this;
}
}
);
$("#a1").animate({width: maxWidth+"px", opacity: 1.0}, { queue:false, duration:400});
});
Is there a way to keep an element's background unaffected by opacity?
I.E. I have an jquery accordion that when clicked/hovered the contents of the particular element(li) opacity changes causing you to see other elements beneath.
I wondered if I could change it, so there was a solid white background on each list element that doesn't fade ?
Some Code:
<div id="accord_container"><div id="accord">
<ul>
<li><a id="a1"><img src="img/accord/1.jpg" /></a></li>
<li><a id="a2"><img src="img/accord/3.jpg" /></a></li>
<li><a id="a3"><img src="img/accord/7.jpg" /></a></li>
<li><a id="a4"><img src="img/accord/8.jpg" /></a></li>
</ul>
</div></div>
#accord_container{width:930px; margin:0px auto;}
#accord{height:480px; overflow:hidden; margin:5px; position:relative; cursor:pointer;}
#accord ul{position:relative; list-style:none; margin:0; padding:0;}
#accord ul li{float:left; display:block; margin-right:0px; background-color:#FFF;}
#accord ul li a{display:block; overflow:hidden; height:480px; width:72px; opacity:0.75; -ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=75)"; filter:alpha(opacity=75);}
#accord ul li img{position:absolute;}
#a1{width:700px; opacity:1.0; -ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=100)"; filter:alpha(opacity=100);}
$(document).ready(function(){
lastBlock = $("#a1");
maxWidth = 700;
minWidth = 72;
$("#accord ul li a").click(
function(){
if(lastBlock.id == this.id || (lastBlock.id == undefined && this.id == "a1")){
if(this.rel){
window.location=this.rel;
}
}else{
$(lastBlock).animate({width: minWidth+"px", opacity: 0.75}, { queue:false, duration:400});
$(this).animate({width: maxWidth+"px", opacity: 1.0}, { queue:false, duration:400});
lastBlock = this;
}
}
);
$("#a1").animate({width: maxWidth+"px", opacity: 1.0}, { queue:false, duration:400});
});
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您只需要包装内容即可。因此,如果您具有以下结构(仅作为示例):
您可以设置内部 div 的不透明度,而不会影响具有背景的外部 div。
You will just need to wrap the content. So if you have the following structure (just an example):
You can then set the opacity of the inner div without affecting the outer div which has a background.