背景不透明度

发布于 2024-11-28 21:20:28 字数 1921 浏览 0 评论 0原文

有没有办法保持元素的背景不受不透明度的影响?

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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

蓝戈者 2024-12-05 21:20:28

您只需要包装内容即可。因此,如果您具有以下结构(仅作为示例):

<div class="hasBackground">
    <div class="theContent">

    </div>
</div>

您可以设置内部 div 的不透明度,而不会影响具有背景的外部 div。

You will just need to wrap the content. So if you have the following structure (just an example):

<div class="hasBackground">
    <div class="theContent">

    </div>
</div>

You can then set the opacity of the inner div without affecting the outer div which has a background.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文