CSS div opacity仅在外部div上

时间:2013-11-21 21:02:15

标签: css html styles opacity

我有两个div,外部和内部div。我有一个背景图像,外部div有一个不透明度设置,但我似乎无法让内部div不继承外部div的不透明度。我希望内部div是纯色。

我的代码在下面,并且在这里有一个jsfiddle:http://jsfiddle.net/3TK3U/

<style type="text/css">

body
{
background-image:url('http://media-bubble.info/images/layout/background.png');
}

.outsideBox {
    width:70%;
    height:200px;
    background-color: #ffffff;
    opacity:0.7; 
    filter:alpha(opacity=70);
    text-align:center;
}

.insideBox {
    width:40%;
    height:80px;
    background-color: #999;
    z-index:999999;
}

</style>


<div id="Introduction" class="outsideBox">
    <div id="Introduction" class="insideBox">This is the inside box which should not inherit transparancy</div>
</div>

1 个答案:

答案 0 :(得分:22)

尝试使用     background-color: rgba(255,255,255,0.7); 没有不透明度或过滤器,应该使背景透明但不影响元素的内容。