0

I have a fixed div overlay (whole screen) which contain another smaller centered div for a message.

The big div has position:fixed and opacity.

The inner div also has position:fixed but without opacity

But in the inner div , I don't want to have any transparency.(opacity: 1) :

Problem:

I still see it as transparent. How can I fix it ( the inner div) ?

enter image description here

the inner div background-color is black. and the color is red. and (as you can see) it is not what is happening. ( I also tried !important)

Full JSBIN

NB

the overlay div and inner div should not be scrolled when user scrolls.

4

3 回答 3

3

只需将不透明的 div 放在不透明的 div 之外。

http://jsbin.com/icuXOrI/11/edit?html,js,输出

它有position:fixed所以我不管你把它放在哪里。

于 2013-08-26T10:30:29.860 回答
2

您可以使用使背景颜色透明background-color: rgba(0,0,0,0.5)

于 2013-08-26T10:27:35.910 回答
0

保留两个不同的 div,一个不透明,另一个不透明。

<div parent>
    <div with opacity></div>
    <div without opacity></div>
</div>

JSBIN

于 2013-08-26T10:41:46.037 回答