问题描述
我有以下代码。请帮助我如何在模式打开时增加不透明度或如何使背景变暗。
这里是working example
解决方法
将此第backgroundColor
个属性添加到第57行的Modal
组件中:
style={{
display: this.state.display,backgroundColor: this.state.modalShow ? "red" : "none"
}}
这是什么意思,当modalShow
状态为真(也就是显示状态)时,backgroundColor
返回red
和none
。要使其变暗,您可以使用rgba(0,.2)
代替red
显然
编辑:sandbox