-2
我有一个背景和不透明度设置的容器。其中,我有一个孩子。我希望孩子出现在容器的顶部,但不是,不透明会影响孩子。影响孩子的div容器的不透明度
这里的HTML
<div class="container">
<div class="child">some label</div>
</div>
和CSS:
.container {
position: absolute;
top: 0;
width: 200px;
height: 200px;
opacity: 0.5;
background-color: lightblue;
z-index: 10;
}
.child {
position: absolute;
right: 0;
bottom: 0;
}
其他原因,容器必须有一个PO绝对的。
jsfiddle是here。
如何避免影响孩子的容器的不透明度?
@NenadVracar您是说'RGBA(207230237,0.5)' –
设置一个[伪元素]在'background'和'opacity'(https://developer.mozilla.org/en/docs/Web/CSS/Pseudo-elements)示例小提琴:https://jsfiddle.net/L60mqe5a/ –
谢谢大家,作品 – Mark