【问题标题】:Returning the opacity of contents inside a low-opacity div [duplicate]返回低不透明度div中内容的不透明度[重复]
【发布时间】:2012-12-13 04:38:50
【问题描述】:

可能重复:
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 在渲染后具有像OffDiv(意思是0.4)一样的低不透明度。

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

【问题讨论】:

  • 包含 div 的不透明度将继续影响任何子元素。要么在该 div 上设置不透明度,要么从 div 中删除图像。
  • 好的,我想在 offDiv 中上下滑动...所以如果我把 img 放在另一个 div 中,我如何同步 sildeUp 和 Down?

标签: jquery html css opacity


【解决方案1】:

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

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

http://jsfiddle.net/aqHXB/

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2011-01-25
    • 2011-07-05
    • 2012-08-06
    • 1970-01-01
    • 2018-04-19
    • 2012-09-20
    • 2023-02-07
    相关资源
    最近更新 更多