影响子元素的不透明度CSS
我正在尝试在用户禁用 javascript 时实现错误消息。我为我当前的工作创建了一个 jsfiddle 。我有 2 个 div 层,一个覆盖整个页面,另一个在上面显示警告消息,但不透明度设置影响覆盖层也会影响警告消息。我尝试过使用之前问题中的技术,但无法使其发挥作用。谁能帮助我吗?
I am trying to implement an error message when user has disabled javascript. I have created a jsfiddle for my current work. I have 2 div layers one covering the whole page and an another one on top of that to show the warning message, but the opacity settings affects for the cover layer affects the warning message also. I have tried using the techniques from previous questions but I could not make it work. Can anyone help me?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
更多
发布评论
评论(3)
只需将消息移到褪色容器之外...
从:
到:
http://jsfiddle.net/xcPcv/7/
Just move the message outside of the faded container ...
From:
To:
http://jsfiddle.net/xcPcv/7/
使用 rgba(0,0,0,.75) 作为背景,而不是不透明度:
http://jsfiddle。净/xcPcv/9/
Instead of opacity, use rgba(0,0,0,.75) for the background:
http://jsfiddle.net/xcPcv/9/
问题是不透明度适用于所有包含的(子)元素,而不仅仅是您要应用
的元素。这样做的副作用是进一步的不透明度设置将是父不透明度的那一部分。
在您的情况下,您只需将弹出 div 移到 fadeMe div 之外即可
The issue is that opacity applies to all contained (child) elements, not just the element you are applying
to. A side effect of this is that a further opacity setting will be that fraction of the parent opacity.
In your case you need to do nothing else but move the popup div outside the fadeMe div