返回低不透明度div内的不透明度

时间:2012-12-12 19:58:30

标签: jquery html css opacity

  

可能重复:
  I do not want to inherit the child opacity from the parent in CSS

我的页面包含以下<div>

<div id="OffDiv">
    <asp:Image ID="imgHammer" runat="server" ImageUrl="~/Images/hammer.png" ToolTip="Biding..." />
</div>

和css:

div#OffDiv
{
    display: block;
    position: fixed;
    top: 0px;
    right: 0px;
    width: 100%;
    height: 100%;
    padding: 0px;
    margin: 0px;
    z-index: 90000;
    background-color: Blue;
    filter: alpha(opacity=40); /* internet explorer */
    -khtml-opacity: 0.4; /* khtml, old safari */
    -moz-opacity: 0.4; /* mozilla, netscape */
    opacity: 0.4; /* fx, safari, opera */
    text-align: center;
}
#imgHammer
{
    margin-top: 100px;
    z-index: 90001
     filter: alpha(opacity=100); /* internet explorer */
    -khtml-opacity: 1; /* khtml, old safari */
    -moz-opacity: 1; /* mozilla, netscape */
    opacity: 1; /* fx, safari, opera */
    z-index: 90001;
}

问题是imgHammer在呈现后具有低{0}的不透明度(意味着.4)。

如何将其不透明度更改为1?

1 个答案:

答案 0 :(得分:1)

只需使用rgba颜色(0-256而不是00-FF):

background-color: rgba(0,0,0,0.5);

http://jsfiddle.net/aqHXB/