自定义模态背景变暗

问题描述

我有以下代码。请帮助我如何在模式打开时增加不透明度或如何使背景变暗。

这里是working example

解决方法

将此第backgroundColor个属性添加到第57行的Modal组件中:

style={{
  display: this.state.display,backgroundColor: this.state.modalShow ? "red" : "none"
}}

这是什么意思,当modalShow状态为真(也就是显示状态)时,backgroundColor返回rednone。要使其变暗,您可以使用rgba(0,.2)代替red显然

编辑:sandbox