css - 不透明背景上的多个 Div/类

标签 css html opacity

我的目标(以及如何做的问题)是在不透明区域上有一个不透明/白色背景和黑色区域作为内容持有者。这是我现在拥有的:

/* translucent background*/
.background 
{
    width:950px;
    height:1024px;
    margin: 9px auto 10px;

    background-color:#ffffff;
    opacity:0.35;
    filter:alpha(opacity=35); /* For IE8 and earlier */
    border-radius: 15px;
    -moz-border-radius: 15px;
    z-index:0;
}

/*content wrapper*/
.content 
{
    font-family: Arial;
    font-size: 11px;

    width:950px;
    height:1024px;
    margin: 9px auto 10px;

    border-radius: 15px;
    -moz-border-radius: 15px;
    z-index:1;
}

/*one of three content fields*/
.anounce_bar
{
    font-family: Arial;
    font-size: 16px;

    width:940px;
    height:225px;
    float: left;

    border: 5px 5px 5px 5px;

    background-color: black;
    border-radius: 15px;
    -moz-border-radius: 15px;
    z-index:2;
}

<div class="background"></div>
<div class="content">
    <!--Top announcement bar-->  
    <div class="anounce_bar">
    </div>

    <!--Left side nav bar-->
<div class="nav" style="height: 1024px; ">
    </div>

    <!--Right side content window-->
    <div class="content_window">

    </div>
</div>

现在它在半透明背景下方显示 anounce_bar。我如何让栏(以及随后的导航和 content_window)位于 .background 之上?

注意:我还有其他内容,包括顶部的“ header ”图片和背景 JPG,可能与此有关。

如有任何帮助,我们将不胜感激。

更新:

这是不透明度继承的问题 - 我使用的解决方法描述得非常好 here

'background' 类变成了没有任何不透明度的#background,并添加了一个新元素:#background .transparency with absolute positioning and opacity。

<div id="background">
    <div class='transparency'></div>
    /*OTHER STUFF*/
</div> 

最佳答案

改变顺序

<div class="anounce_bar"></div>
<div class="background"></div>

这应该有效。

关于css - 不透明背景上的多个 Div/类,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7810695/

相关文章:

php - POST 值并获取页面源

javascript - 页面加载时将不透明度从 0 设置为 1

html - 如何仅在平板电脑及以上尺寸的设备上制作 Bootstrap 输入组?

jquery - 具有平滑位置转换的绝对中心

html - 超链接创建换行符

javascript - 将 html <td> 标签重置为原始颜色

javascript - HTML - 固定 div 仅在滚动后显示在位置 0,0

html - 去掉我网站底部页脚上方的空白

delphi - 在Delphi 2010中绘制不透明度椭圆

css - 当白色 css 文本不透明度低于 1 时,会出现烦人的重叠